@@ -3,28 +3,12 @@ name: Release
33on :
44 push :
55 branches : [main]
6- release :
7- types : [published]
86 workflow_dispatch :
97
10- # ┌─────────────────────────────────────────────────────────────────┐
11- # │ DRAFT_RELEASE │
12- # │ │
13- # │ "true" → GitHub Releases are created as drafts; review them │
14- # │ on GitHub, then click "Publish" to trigger PyPI. │
15- # │ "false" → GitHub Releases are published immediately, which │
16- # │ automatically triggers the PyPI publish job. │
17- # │ │
18- # │ Flip to "false" once you are comfortable with the pipeline. │
19- # └─────────────────────────────────────────────────────────────────┘
20- env :
21- DRAFT_RELEASE : " true"
22-
238jobs :
249 release :
2510 name : Semantic Release
2611 runs-on : ubuntu-latest
27- if : github.event_name != 'release'
2812 concurrency :
2913 group : release
3014 cancel-in-progress : false
@@ -51,71 +35,13 @@ jobs:
5135 uses : python-semantic-release/python-semantic-release@v9
5236 with :
5337 github_token : ${{ secrets.GITHUB_TOKEN }}
54- vcs_release : " false"
5538
5639 - name : Build package
5740 if : steps.release.outputs.released == 'true'
5841 run : python -m build
5942
60- - name : Extract changelog for this release
61- if : steps.release.outputs.released == 'true'
62- id : changelog
63- run : |
64- TAG="${{ steps.release.outputs.tag }}"
65- VER="${TAG#v}"
66- # Extract the section between this version's header and the next
67- awk "/^## v${VER//./\\.} /{found=1; next} /^## v[0-9]/{if(found) exit} found" CHANGELOG.md > /tmp/release_notes.md
68- PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]' | sed -n '2p')
69- if [ -n "$PREV_TAG" ]; then
70- REPO="${{ github.repository }}"
71- printf '\n---\n\n**Detailed Changes**: [%s...%s](https://github.com/%s/compare/%s...%s)\n' \
72- "$PREV_TAG" "$TAG" "$REPO" "$PREV_TAG" "$TAG" >> /tmp/release_notes.md
73- fi
74-
75- - name : Create GitHub Release
76- if : steps.release.outputs.released == 'true'
77- env :
78- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79- run : |
80- if [ "$DRAFT_RELEASE" = "true" ]; then
81- DRAFT_FLAG="--draft"
82- fi
83- gh release create "${{ steps.release.outputs.tag }}" \
84- ${DRAFT_FLAG:-} \
85- --title "${{ steps.release.outputs.tag }}" \
86- --notes-file /tmp/release_notes.md \
87- dist/*
88-
89- - name : Publish to PyPI (non-draft)
90- if : steps.release.outputs.released == 'true' && env.DRAFT_RELEASE != 'true'
91- uses : pypa/gh-action-pypi-publish@release/v1
92- with :
93- skip-existing : true
94-
95- pypi-publish :
96- name : Publish to PyPI
97- runs-on : ubuntu-latest
98- if : github.event_name == 'release' && github.event.action == 'published'
99- permissions :
100- id-token : write
101- steps :
102- - name : Checkout
103- uses : actions/checkout@v4
104- with :
105- ref : ${{ github.event.release.tag_name }}
106-
107- - name : Set up Python
108- uses : actions/setup-python@v5
109- with :
110- python-version : ' 3.12'
111-
112- - name : Install build tools
113- run : python -m pip install -U pip build
114-
115- - name : Build package
116- run : python -m build
117-
11843 - name : Publish to PyPI
44+ if : steps.release.outputs.released == 'true'
11945 uses : pypa/gh-action-pypi-publish@release/v1
12046 with :
12147 skip-existing : true
0 commit comments