| name: Build And Release Wheels | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-latest, macos-15-intel] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Get OCCT cache key | |
| id: occt-key | |
| shell: bash | |
| run: | | |
| # Cache key includes: OS, OCCT commit, patches, and build script | |
| OCCT_COMMIT=$(git rev-parse HEAD:upstream/OCCT) | |
| echo "hash=${{ runner.os }}-${OCCT_COMMIT}-${{ hashFiles('patches/*.patch', 'scripts/build_occt.py') }}" >> $GITHUB_OUTPUT | |
| - name: Cache OCCT build | |
| id: cache-occt | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| upstream/OCCT/lin64 | |
| upstream/OCCT/lin32 | |
| upstream/OCCT/win64 | |
| upstream/OCCT/mac64 | |
| key: occt-${{ steps.occt-key.outputs.hash }} | |
| save-always: true | |
| - uses: ilammy/msvc-dev-cmd@v1.13.0 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v3.4.1 | |
| with: | |
| output-dir: wheelhouse | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| path: ./wheelhouse/*.whl | |
| name: wheels-${{ matrix.os }} | |
| upload_all: | |
| name: Upload To PyPi | |
| needs: build_wheels | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/setup-python@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| merge-multiple: true | |
| path: dist | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@v1.8.12 | |
| release: | |
| permissions: | |
| contents: write # for actions/create-release | |
| name: Create GitHub Release | |
| needs: [build_wheels] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Tag Version | |
| id: set_tag | |
| run: | | |
| export VER=$(python -c "print(next(eval(L.split('=')[-1]) for L in open('pyproject.toml') if L.startswith('version ')))") | |
| echo "::set-output name=tag_name::${VER}" | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ steps.set_tag.outputs.tag_name }} | |
| release_name: Release ${{ steps.set_tag.outputs.tag_name }} | |
| draft: false | |
| prerelease: false |