Publish Existing Tag to PyPI #1
This file contains hidden or 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 Existing Tag to PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to publish (e.g., v1.0.2)' | |
required: true | |
default: 'v1.0.2' | |
jobs: | |
build-and-publish: | |
name: Build and Publish to PyPI | |
runs-on: ubuntu-latest | |
# IMPORTANT: This permission is required for trusted publishing | |
permissions: | |
id-token: write | |
steps: | |
- name: Checkout specific tag | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.tag }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
- name: Build distribution | |
run: python -m build | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
# No need for username/password with trusted publishing! |