开源项目规范化:补全元数据、标准文件、优化 CI #6
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: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| runs-on: macos-14 | |
| name: "arm64 — Python ${{ matrix.python-version }}" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.21" | |
| cache-dependency-path: dpi_bridge/go.sum | |
| - 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 | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: "14.0" | |
| _PYTHON_HOST_PLATFORM: "macosx-14.0-arm64" | |
| 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-arm64-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 |