Skip to content

Publish to PyPI

Publish to PyPI #35

Workflow file for this run

# This will run every time a release is created and published.
# It calls our tests workflow via a `workflow_call`, and if tests pass
# then it triggers our upload to PyPI for a new release.
name: Publish to PyPI
on:
release:
types:
- published
workflow_dispatch:
env:
FORCE_COLOR: "1" # Make tools pretty.
permissions:
contents: read
jobs:
# calls our tests workflow
tests:
permissions:
pull-requests: write
contents: write
uses: ./.github/workflows/tests.yml
build-package:
name: "Build & verify PST package"
needs: [tests] # require tests to pass before deploy runs
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Set up Python 3.9"
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: "Install gettext for translations 🌐"
run: |
sudo apt-get install gettext
- name: "Build and inspect package 📦"
uses: hynek/build-and-inspect-python-package@v2
id: baipp
- run: echo Packages can be found at ${{ steps.baipp.outputs.dist }}
release-pypi:
runs-on: ubuntu-latest
needs: [build-package]
permissions:
id-token: write # needed for PyPI upload
steps:
- name: "Download PST built package 📦"
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: "Unzip artifact"
run: |
tar xf dist/*.tar.gz --strip-components=1
- name: "Publish PST package to PyPI 🚀"
uses: pypa/gh-action-pypi-publish@release/v1
# only publish if this is a published release by pydata
if: github.repository_owner == 'pydata' && github.event_name == 'release' && github.event.action == 'published'