|
1 | | -name: Release |
| 1 | +# New release tags trigger this workflow to publish to test.pypi.org. |
| 2 | +# If that looks good, a `workflow_dispatch` can be used to publish to pypi.org (with `prod-pypi` set to 'true'). |
| 3 | +name: Publish to PyPI |
2 | 4 | on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v[0-9]+*' |
3 | 8 | workflow_dispatch: |
4 | 9 | inputs: |
5 | | - tag: |
6 | | - description: 'The tag version to release (e.g., v1.0.0)' |
7 | | - required: true |
8 | | - default: 'v0.1.0alpha' |
9 | | - environment: |
10 | | - description: 'PyPI environment to release to (test or production)' |
11 | | - required: true |
12 | | - default: 'test' |
13 | | - |
| 10 | + prod-pypi: |
| 11 | + type: boolean |
| 12 | + description: 'Publish to pypi.org (default: test.pypi.org)' |
| 13 | + ref: |
| 14 | + description: 'Git ref to checkout, build, and publish' |
| 15 | + verbose: |
| 16 | + type: boolean |
| 17 | + description: 'Enable debug output from pypa/gh-action-pypi-publish' |
14 | 18 | jobs: |
15 | | - pypi-publish: |
16 | | - name: upload release to PyPI |
| 19 | + build: |
| 20 | + name: Build package |
17 | 21 | runs-on: ubuntu-latest |
18 | | - environment: pypi |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + ref: ${{ inputs.ref || '' }} |
| 27 | + - uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: '3.11.11' |
| 30 | + - name: Build package |
| 31 | + run: | |
| 32 | + pip install build |
| 33 | + python -m build |
| 34 | + ls -l dist |
| 35 | + - name: Upload distributions |
| 36 | + uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: python-package-distributions |
| 39 | + path: dist/ |
| 40 | + retention-days: 1 |
| 41 | + publish: |
| 42 | + name: Upload release to ${{ inputs.prod-pypi != true && 'test ' || '' }}PyPI |
| 43 | + needs: build |
| 44 | + runs-on: ubuntu-latest |
| 45 | + environment: |
| 46 | + name: pypi |
| 47 | + url: https://${{ inputs.prod-pypi != true && 'test.' || '' }}pypi.org/p/tiledbsoma_ml # Displayed in GHA UI |
19 | 48 | permissions: |
20 | 49 | id-token: write |
21 | 50 | steps: |
22 | | - - name: Setup Python |
23 | | - uses: actions/setup-python@v5 |
24 | | - - name: Checkout |
25 | | - uses: actions/checkout@v4 |
26 | | - - name: Build package |
27 | | - run: pip install build && python -m build && ls -l dist |
28 | | - - name: Publish package distributions to Test PyPI |
29 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
30 | | - continue-on-error: true |
| 51 | + - name: Print inputs |
| 52 | + run: | |
| 53 | + echo "Inputs: ${{ toJSON(github.event.inputs) }}" |
| 54 | + - name: Download distributions |
| 55 | + uses: actions/download-artifact@v4 |
31 | 56 | with: |
32 | | - repository_url: https://test.pypi.org/legacy/ |
33 | | - - name: Publish package distributions to PyPI |
34 | | - if: "!github.event.release.prerelease" |
| 57 | + name: python-package-distributions |
| 58 | + path: dist/ |
| 59 | + - name: Publish package distributions to ${{ inputs.prod-pypi != true && 'test ' || '' }}PyPI |
35 | 60 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 61 | + with: |
| 62 | + repository-url: ${{ inputs.prod-pypi != true && 'https://test.pypi.org/legacy/' || '' }} |
| 63 | + verbose: ${{ inputs.verbose }} |
0 commit comments