ci: publish the CLI to PyPI on cli-vX.Y.Z tags (Trusted Publishing)
This commit is contained in:
parent
965ffa90fb
commit
89f0309343
1 changed files with 42 additions and 0 deletions
42
.github/workflows/publish-cli.yml
vendored
Normal file
42
.github/workflows/publish-cli.yml
vendored
Normal 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/
|
||||||
Loading…
Reference in a new issue