Build and upload to PyPI #4
This file contains 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 and upload to PyPI | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
name: Build universal wheel and source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install-test-and-build | |
with: | |
extras-require: publishing | |
- name: Build wheel and source distribution | |
run: python -m build | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/* | |
upload_test_pypi: | |
needs: [build] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/distance_explainer | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true # https://github.com/marketplace/actions/pypi-publish#for-debugging | |
upload_pypi: | |
needs: [build] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'published' | |
environment: | |
name: pypi | |
url: https://pypi.org/p/distance_explainer | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true |