Publish to (Test)PyPI #24
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 to (Test)PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to upload to pypi' | |
required: true | |
pypi_repo: | |
description: 'Repo to upload to ("testpypi" or "pypi")' | |
default: 'testpypi' | |
required: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
# Specifying a GitHub environment is optional, but strongly encouraged | |
environment: publish-pypi | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.version }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip | |
python -m pip install -U setuptools wheel twine build | |
- name: Generate distribution archives | |
run: | | |
python -m build | |
- name: Publish package to TestPyPI | |
uses: pypa/gh-action-pypi-publish@v1.8.10 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
if: ${{ github.event.inputs.pypi_repo == 'testpypi' }} | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.8.10 | |
if: ${{ github.event.inputs.pypi_repo == 'pypi' }} |