Add a [reusable] workflow for building wheels #16
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 struct2tensor wheels | |
| on: | |
| pull_request: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Build package | |
| id: build-package | |
| uses: ./.github/reusable-build | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: List and check wheels | |
| shell: bash | |
| run: | | |
| pip install twine | |
| ls -lh dist/ | |
| twine check dist/* | |
| upload_to_pypi: | |
| name: Upload to PyPI | |
| runs-on: ubuntu-latest | |
| if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch') | |
| needs: [build] | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/struct2tensor/ | |
| permissions: | |
| id-token: write | |
| contents: read | |
| attestations: write | |
| steps: | |
| - name: Retrieve wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| path: wheels | |
| - name: List the build artifacts | |
| run: | | |
| ls -lAs wheels/ | |
| - name: Generate artifact attestations for wheels | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-path: "wheels/*" | |
| - name: Upload to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages_dir: wheels/ |