mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-24 21:04:48 -06:00
5bc04fc313
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
72 lines
2.7 KiB
YAML
72 lines
2.7 KiB
YAML
name: Publish to PyPI
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["CI"]
|
|
types: [completed]
|
|
|
|
concurrency:
|
|
group: publish-${{ github.event.workflow_run.head_sha }}
|
|
# Never cancel a publish mid-upload: a half-uploaded release (sdist up,
|
|
# wheel missing) cannot be re-run cleanly because PyPI rejects duplicates.
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
publish:
|
|
# workflow_run fires for EVERY CI completion — including CI runs for
|
|
# pull_requests from forks — and always executes here with this repo's
|
|
# secrets, tokens, and the pypi environment. Gate to same-repo tag
|
|
# pushes only: CI's push trigger matches branches main/stable/* and
|
|
# tags v*, so a head_branch starting with "v" is necessarily a tag run.
|
|
if: >-
|
|
github.event.workflow_run.conclusion == 'success' &&
|
|
github.event.workflow_run.event == 'push' &&
|
|
github.event.workflow_run.head_repository.full_name == github.repository &&
|
|
startsWith(github.event.workflow_run.head_branch, 'v')
|
|
runs-on: ubuntu-latest
|
|
environment: pypi
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
ref: ${{ github.event.workflow_run.head_sha }}
|
|
fetch-depth: 0
|
|
# python -m build executes the tree's build backend; don't leave
|
|
# the contents:write token sitting in .git/config while it runs.
|
|
persist-credentials: false
|
|
|
|
- name: Resolve release tag
|
|
id: tag
|
|
run: |
|
|
TAG=$(git tag --points-at HEAD | grep '^v' | head -1)
|
|
if [ -z "$TAG" ]; then
|
|
echo "No v* tag at HEAD — skipping publish"
|
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
|
|
if: steps.tag.outputs.skip == 'false'
|
|
with:
|
|
python-version: "3.14"
|
|
- run: pip install build
|
|
if: steps.tag.outputs.skip == 'false'
|
|
- run: python -m build
|
|
if: steps.tag.outputs.skip == 'false'
|
|
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
|
|
if: steps.tag.outputs.skip == 'false'
|
|
|
|
- name: Create GitHub Release
|
|
if: steps.tag.outputs.skip == 'false'
|
|
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
|
|
with:
|
|
tag_name: ${{ steps.tag.outputs.tag }}
|
|
generate_release_notes: true
|
|
draft: false
|
|
prerelease: ${{ contains(steps.tag.outputs.tag, 'a') || contains(steps.tag.outputs.tag, 'b') || contains(steps.tag.outputs.tag, 'rc') }}
|