Publish library to PyPI #12
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: "Publish library to PyPI" | |
on: | |
workflow_run: | |
workflows: ["Setup, Build, and Test"] | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
publish: | |
name: Publish library | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
matrix: | |
python-version: ["3.11"] | |
permissions: | |
contents: read | |
actions: read # IMPORTANT: mandatory for downloading artifacts | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'poetry' | |
- name: Download built package | |
uses: actions/download-artifact@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.workflow_run.id }} | |
name: built-package | |
path: dist/ | |
- name: Publish package to PyPI | |
run: poetry publish --username '__token__' --password ${{ secrets.PYPI_API_KEY }} |