| 1 |
name: Upload Python Package |
| 2 |
|
| 3 |
# The tag is now triggered by the Github App: CommitizenBot |
| 4 |
on: |
| 5 |
push: |
| 6 |
tags: |
| 7 |
- "v*" |
| 8 |
# Manual trigger for republishing a specific tag if the original push-on-tag |
| 9 |
# run failed and is now too old to be re-run via the GitHub UI (#1790). |
| 10 |
# ``ref`` should be a tag name like ``v4.11.1``. |
| 11 |
workflow_dispatch: |
| 12 |
inputs: |
| 13 |
ref: |
| 14 |
description: "Tag to republish (e.g., v4.11.1)" |
| 15 |
required: true |
| 16 |
type: string |
| 17 |
|
| 18 |
jobs: |
| 19 |
deploy: |
| 20 |
if: ${{ github.repository == 'commitizen-tools/commitizen' }} |
| 21 |
runs-on: ubuntu-latest |
| 22 |
permissions: |
| 23 |
id-token: write |
| 24 |
contents: read |
| 25 |
steps: |
| 26 |
- name: Validate dispatch ref is a tag |
| 27 |
if: github.event_name == 'workflow_dispatch' |
| 28 |
env: |
| 29 |
TAG: ${{ github.event.inputs.ref }} |
| 30 |
run: | |
| 31 |
if ! git ls-remote --tags "https://github.com/${GITHUB_REPOSITORY}" "refs/tags/${TAG}" | grep -q .; then |
| 32 |
echo "::error::Dispatch ref '${TAG}' is not an existing tag" |
| 33 |
exit 1 |
| 34 |
fi |
| 35 |
- uses: actions/checkout@v7 |
| 36 |
with: |
| 37 |
fetch-depth: 0 |
| 38 |
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.ref) || github.ref }} |
| 39 |
- name: Set up Python |
| 40 |
uses: astral-sh/setup-uv@v7 |
| 41 |
- name: Build |
| 42 |
run: uv build |
| 43 |
- name: Publish package to PyPI |
| 44 |
uses: pypa/gh-action-pypi-publish@release/v1 |