diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml new file mode 100644 index 0000000..f62a84f --- /dev/null +++ b/.github/workflows/publish-cli.yml @@ -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/