Skip to content

v0.3.3

v0.3.3 #7

Workflow file for this run

name: Release to PyPI
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
# Trusted publishing: no API token needed. Configure once at
# https://pypi.org/manage/account/publishing/ with:
# PyPI Project: state-trace
# Owner: razroo
# Repository: state-trace
# Workflow: release.yml
# Environment: pypi
environment:
name: pypi
url: https://pypi.org/p/state-trace
permissions:
contents: read
id-token: write # required for PyPI OIDC + provenance attestation
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Derive version from release tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Wait for CI to succeed on release commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SHA=$(git rev-parse HEAD)
echo "Verifying CI check-run 'ci-pass' for $SHA"
# Poll until the aggregator check-run from .github/workflows/ci.yml
# completes. Refuse publish on any non-success conclusion. Polling
# is required because `release: published` often fires before the
# push-triggered CI workflow has registered its check-run.
DEADLINE=$(( $(date +%s) + 1800 )) # 30 min
STATUS=""
CONCLUSION=""
while [ "$(date +%s)" -lt "$DEADLINE" ]; do
read -r STATUS CONCLUSION <<<"$(gh api "repos/${{ github.repository }}/commits/$SHA/check-runs" \
--jq '[.check_runs[] | select(.name == "ci-pass")] | sort_by(.started_at) | last | "\(.status // "missing") \(.conclusion // "null")"')"
echo "ci-pass check-run: status=$STATUS conclusion=$CONCLUSION"
if [ "$STATUS" = "completed" ]; then
break
fi
sleep 15
done
if [ "$STATUS" != "completed" ]; then
echo "::error::CI for $SHA never completed within 30min (last status: $STATUS)."
exit 1
fi
if [ "$CONCLUSION" != "success" ]; then
echo "::error::CI for $SHA did not succeed (conclusion: $CONCLUSION). Fix CI before re-releasing."
exit 1
fi
echo "CI succeeded for $SHA"
- name: Verify pyproject.toml version matches release tag
run: python scripts/release/check_version.py "$VERSION"
- name: Install build tooling
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist and wheel
run: python -m build
- name: Publish to PyPI with provenance
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true