Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
ecdbde7d0This file is pinned to the selected release. Download the original to open it in your design tool.
# Release pipeline — builds the package, publishes a GitHub Release with the
# sdist + wheel attached, and (only if configured) publishes to PyPI via
# trusted publishing. See docs/releasing.md for the operator runbook.
#
# PyPI publishing (job `publish-pypi`) is gated on the repository/environment
# variable `PYPI_TRUSTED_PUBLISHING` being set to "true" on the `pypi`
# GitHub Environment. Repos that haven't set that up are skipped gracefully —
# the release job's success never depends on PyPI being configured.
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch: {}
permissions:
contents: write # create the GitHub Release + upload assets
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
name: build + GitHub Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
steps:
- name: Guard — must run on a tag
if: ${{ github.ref_type != 'tag' }}
run: |
echo "::error::This workflow must be triggered by a v* tag (ref_type=${{ github.ref_type }})."
exit 1
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Derive + verify version (tag must match pyproject)
id: ver
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
ver="${tag#v}"
py="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$ver" >> "$GITHUB_OUTPUT"
if [ "$ver" != "$py" ]; then
echo "::error::Tag $tag (version $ver) != pyproject version $py. Bump pyproject + manifests, then re-tag."
exit 1
fi
if printf '%s' "$tag" | grep -q '-'; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Manifest version-sync check
if: ${{ hashFiles('tools/sync_version.py') != '' }}
run: python tools/sync_version.py --check
- name: Build sdist + wheel
run: |
python -m pip install --upgrade build twine
python -m build
twine check dist/*
- name: Extract release notes from CHANGELOG
run: python tools/changelog_extract.py "${{ steps.ver.outputs.version }}" > release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.tag }}
body_path: release-notes.md
prerelease: ${{ steps.ver.outputs.prerelease }}
fail_on_unmatched_files: true
files: |
dist/*.whl
dist/*.tar.gz
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
retention-days: 7
# ---------------------------------------------------------------------------
# PyPI publish via trusted publishing (OIDC, no long-lived token). Skipped
# gracefully when the repo hasn't opted in — set the `PYPI_TRUSTED_PUBLISHING`
# variable to "true" on the `pypi` GitHub Environment (Settings > Environments
# > pypi > Variables) once PyPI trusted publishing is configured for this repo.
# ---------------------------------------------------------------------------
publish-pypi:
name: publish to PyPI
needs: release
if: ${{ vars.PYPI_TRUSTED_PUBLISHING == 'true' }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/akcli/${{ needs.release.outputs.version }}/
permissions:
id-token: write # OIDC token for trusted publishing; no API token/secret needed
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true