Use build-and-inspect and pypi-publish actions #1
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: Publish to PyPI | |
| on: | |
| push: | |
| branches: [main, dev, deno-binary] | |
| tags: ['*'] | |
| pull_request: | |
| brainches: [main, dev] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build_wheels: | |
| name: Build whl on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| # Changing this requires changing pyproject.toml | |
| EXECUTABLE: bids-validator | |
| strategy: | |
| matrix: | |
| # windows-latest is an Intel runner | |
| # macos-13 is an Intel runner, macos-latest is an Apple Silicon runner | |
| # ubuntu-latest is an Intel runner, ubuntu-24.04-arm is an arm runner | |
| os: | |
| - windows-latest | |
| - macos-13 | |
| - macos-latest | |
| - ubuntu-latest | |
| - ubuntu-24.04-arm | |
| fail-fast: false | |
| permissions: | |
| attestations: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Compile deno binaries | |
| run: | | |
| deno compile -ERNW --allow-run -o dist/${EXECUTABLE} ../../src/bids-validator.ts | |
| working-directory: tools/pypi-whl | |
| - name: Print out the content of the dist folder after building validator binary | |
| run: ls -l tools/pypi-whl/dist/ | |
| - uses: hynek/build-and-inspect-python-package@v2 | |
| with: | |
| # Use attestation only if the action is triggered inside the repo | |
| attest-build-provenance-github: ${{ github.event_name == 'push' }} | |
| path: tools/pypi-whl | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3 | |
| - name: Check wheel | |
| run: | |
| pip install tools/pypi-whl/dist/*.whl | |
| ${EXECUTABLE} --version | |
| upload_wheels: | |
| name: Publish wheels to PyPI | |
| needs: [build_wheels] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download packages built by build-and-inspect-python-package | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Inspect artifacts | |
| run: ls -lR | |
| - name: Upload package to PyPI | |
| if: github.ref_type == 'tag' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true |