开源合规调整 + GitHub Actions CI 构建 macOS wheel #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build macOS wheels | |
| on: | |
| push: | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: macos-14 | |
| arch: arm64 | |
| - runner: macos-13 | |
| arch: x86_64 | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| runs-on: ${{ matrix.runner }} | |
| name: "${{ matrix.arch }} — Python ${{ matrix.python-version }}" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.21" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Decode DPI headers | |
| env: | |
| DPI_HEADERS_TAR_B64: ${{ secrets.DPI_HEADERS_TAR_B64 }} | |
| run: | | |
| mkdir -p dpi_include | |
| echo "$DPI_HEADERS_TAR_B64" | base64 -d | tar xzf - -C dpi_include/ | |
| - name: Build Go bridge library | |
| run: | | |
| cd dpi_bridge && go build -buildmode=c-shared -o libdmdpi.dylib . | |
| install_name_tool -id @rpath/libdmdpi.dylib libdmdpi.dylib | |
| - name: Install build tools | |
| run: pip install build delocate | |
| - name: Build wheel | |
| run: DMPYTHON_SKIP_GO_BUILD=1 python -m build --wheel | |
| - name: Delocate wheel | |
| run: | | |
| mkdir -p dist_fixed | |
| DYLD_LIBRARY_PATH=dpi_bridge delocate-wheel -w dist_fixed dist/*.whl -v | |
| - name: Verify wheel | |
| run: | | |
| python -m venv /tmp/test_venv | |
| /tmp/test_venv/bin/pip install dist_fixed/*.whl | |
| /tmp/test_venv/bin/python -c "import dmPython; print('dmPython version:', dmPython.version)" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.arch }}-py${{ matrix.python-version }} | |
| path: dist_fixed/*.whl | |
| release: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: macos-14 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist_fixed | |
| pattern: wheel-* | |
| merge-multiple: true | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| run: gh release create "$TAG_NAME" --generate-notes dist_fixed/*.whl |