11name : Release
22
33on :
4- release :
5- types : [released]
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Release version (e.g., 2.11.4)'
8+ required : true
9+ type : string
610
711concurrency :
812 group : release
@@ -13,22 +17,87 @@ permissions:
1317
1418jobs :
1519
20+ create_release :
21+ name : Create Draft Release
22+ runs-on : ubuntu-24.04
23+ if : github.ref == 'refs/heads/main'
24+ permissions :
25+ contents : write
26+ outputs :
27+ release_id : ${{ steps.create_release.outputs.release_id }}
28+ steps :
29+ - name : Checkout
30+ uses : actions/checkout@v4.2.2
31+ with :
32+ fetch-depth : 1
33+ show-progress : false
34+ persist-credentials : false
35+
36+ - name : Generate Release Notes
37+ env :
38+ VERSION : ${{ inputs.version }}
39+ run : |
40+ cp .github/release_preamble.md release_body.md
41+ changelog_section=$(awk '/^## \['"$VERSION"'\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md)
42+ if [ -z "$changelog_section" ]; then
43+ echo "Error: No changelog section found for version $VERSION"
44+ exit 1
45+ fi
46+ echo "$changelog_section" >> release_body.md
47+
48+ - name : Create Draft Release
49+ id : create_release
50+ env :
51+ VERSION : ${{ inputs.version }}
52+ run : |
53+ release_id=$(gh release create "$VERSION" \
54+ --draft \
55+ --title "$VERSION" \
56+ --notes-file release_body.md \
57+ --json id | jq -r .id)
58+ echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
59+
1660 create_artifacts :
1761 name : Create Artifacts
18- uses : ./.github/workflows/release_artifacts .yaml
62+ uses : ./.github/workflows/create_release_artifacts .yaml
1963 with :
20- release_version : ${{ github.event.release.tag_name }}
64+ release_version : ${{ inputs.version }}
2165
22- publish-to-pypi :
23- name : Publish to PyPI
66+ upload_artifacts :
67+ name : Upload Artifacts to Release
2468 needs :
69+ - create_release
2570 - create_artifacts
2671 runs-on : ubuntu-24.04
72+ permissions :
73+ contents : write
74+ steps :
75+ - name : Download distribution artifacts
76+ uses : actions/download-artifact@v4.1.8
77+ with :
78+ pattern : dist-*
79+ path : dist/
80+ merge-multiple : true
81+
82+ - name : Upload Release Assets
83+ env :
84+ VERSION : ${{ inputs.version }}
85+ run : |
86+ gh release upload "$VERSION" \
87+ dist/${{ needs.create_artifacts.outputs.sdist }} \
88+ dist/${{ needs.create_artifacts.outputs.py3_wheel }} \
89+ dist/${{ needs.create_artifacts.outputs.py2_wheel }}
90+
91+ publish_to_pypi :
92+ name : Publish to PyPI
93+ needs :
94+ - upload_artifacts
95+ runs-on : ubuntu-24.04
2796 permissions :
2897 id-token : write
2998 environment :
3099 name : pypi
31- url : https://pypi.org/project/python-minifier/${{ github.event.release.tag_name }}
100+ url : https://pypi.org/project/python-minifier/${{ inputs.version }}
32101 steps :
33102 - name : Download distribution artifacts
34103 uses : actions/download-artifact@v4.1.8
@@ -38,15 +107,15 @@ jobs:
38107 merge-multiple : true
39108
40109 - name : Publish package distributions to PyPI
41- uses : pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
110+ uses : pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
42111 with :
43112 print-hash : true
44113 verbose : true
45114
46- publish-docs :
115+ publish_docs :
47116 name : Publish Documentation
48117 needs :
49- - create_artifacts
118+ - upload_artifacts
50119 runs-on : ubuntu-24.04
51120 permissions :
52121 pages : write
@@ -58,3 +127,16 @@ jobs:
58127 - name : Deploy to GitHub Pages
59128 id : deployment
60129 uses : actions/deploy-pages@v4.0.5
130+
131+ publish_release :
132+ name : Publish Release
133+ needs :
134+ - publish_to_pypi
135+ - publish_docs
136+ runs-on : ubuntu-24.04
137+ permissions :
138+ contents : write
139+ steps :
140+ - name : Publish Release
141+ run : |
142+ gh release edit ${{ inputs.version }} --draft=false
0 commit comments