ci: publish the CLI to PyPI on cli-vX.Y.Z tags (Trusted Publishing)

This commit is contained in:
victorcavero14 2026-09-27 21:24:48 +02:00
parent 965ffa90fb
commit 89f0309343

42
.github/workflows/publish-cli.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Publish CLI to PyPI
# Push a tag cli-vX.Y.Z (matching `version` in cli/pyproject.toml) to publish
# the `openshorts` CLI. Uses PyPI Trusted Publishing (OIDC): no API token.
on:
push:
tags:
- "cli-v*.*.*"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Tag matches cli/pyproject.toml version
if: startsWith(github.ref, 'refs/tags/')
run: |
v=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
[ "cli-v$v" = "${GITHUB_REF_NAME}" ] || { echo "tag ${GITHUB_REF_NAME} != cli-v$v"; exit 1; }
- name: Build
run: |
pip install build
python -m build
- name: Smoke test the wheel
run: |
pip install dist/*.whl
openshorts --help
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: cli/dist/