Skip to content

Commit 6b97e82

Browse files
committed
Test draft release and upload
1 parent fe4fc2c commit 6b97e82

File tree

5 files changed

+185
-14
lines changed

5 files changed

+185
-14
lines changed

.github/release_preamble.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
:information_source: Note that python-minifier depends on the python interpreter for parsing source code,
2+
and will output source code compatible with the version of the interpreter it is run with.
3+
4+
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
5+
the minified code may only run with Python 3.12.

.github/workflows/release_artifacts.yaml renamed to .github/workflows/create_release_artifacts.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
description: The Python 2 wheel filename
1919
value: ${{ jobs.package_python2.outputs.wheel }}
2020

21+
permissions:
22+
contents: none
23+
2124
jobs:
2225

2326
package_python3:
@@ -42,7 +45,20 @@ jobs:
4245
env:
4346
VERSION: ${{ inputs.release_version }}
4447
run: |
45-
sed -i "s/setup_requires=.*/version='$VERSION',/; s/use_scm_version=.*//" setup.py
48+
python3 -c "
49+
import re, os
50+
version = os.environ['VERSION']
51+
52+
with open('setup.py', 'r') as f:
53+
content = f.read()
54+
55+
# Remove setuptools_scm configuration and set static version
56+
content = re.sub(r'setup_requires=.*', f\"version='{version}',\", content)
57+
content = re.sub(r'use_scm_version=.*,?\s*', '', content)
58+
59+
with open('setup.py', 'w') as f:
60+
f.write(content)
61+
"
4662
echo "Version: $VERSION"
4763
4864
- name: Build distribution packages
@@ -142,6 +158,8 @@ jobs:
142158
name: Test Package
143159
runs-on: ubuntu-24.04
144160
needs: [package_python2, package_python3]
161+
permissions:
162+
contents: read
145163
strategy:
146164
fail-fast: false
147165
matrix:
@@ -190,6 +208,8 @@ jobs:
190208
strategy:
191209
matrix:
192210
package_type: [sdist, wheel]
211+
permissions:
212+
contents: read
193213
container:
194214
image: danielflook/python-minifier-build:python3.14-2025-08-21
195215
steps:

.github/workflows/release.yaml

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
name: Release
22

33
on:
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

711
concurrency:
812
group: release
@@ -13,22 +17,87 @@ permissions:
1317

1418
jobs:
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/[email protected]
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/[email protected]
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/[email protected]
@@ -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/[email protected]
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

.github/workflows/release_test.yaml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,76 @@ jobs:
3030
echo "Version: $VERSION"
3131
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
3232
33+
create_release:
34+
name: Create Draft Release
35+
runs-on: ubuntu-24.04
36+
needs:
37+
- determine_version
38+
permissions:
39+
contents: write
40+
outputs:
41+
release_id: ${{ steps.create_release.outputs.release_id }}
42+
steps:
43+
- name: Checkout
44+
uses: actions/[email protected]
45+
with:
46+
fetch-depth: 1
47+
show-progress: false
48+
persist-credentials: false
49+
50+
- name: Generate Release Notes
51+
env:
52+
VERSION: "Unreleased"
53+
run: |
54+
cp .github/release_preamble.md release_body.md
55+
changelog_section=$(awk '/^## \['"$VERSION"'\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md)
56+
if [ -z "$changelog_section" ]; then
57+
echo "Error: No changelog section found for version $VERSION"
58+
exit 1
59+
fi
60+
echo "$changelog_section" >> release_body.md
61+
62+
- name: Create Draft Release
63+
id: create_release
64+
env:
65+
VERSION: ${{ needs.determine_version.outputs.release_version }}
66+
run: |
67+
release_id=$(gh release create "$VERSION" \
68+
--draft \
69+
--title "$VERSION" \
70+
--notes-file release_body.md \
71+
--json id | jq -r .id)
72+
echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
73+
3374
create_artifacts:
3475
name: Create Artifacts
35-
uses: ./.github/workflows/release_artifacts.yaml
76+
uses: ./.github/workflows/create_release_artifacts.yaml
3677
needs:
3778
- determine_version
3879
with:
3980
release_version: ${{ needs.determine_version.outputs.release_version }}
81+
82+
upload_artifacts:
83+
name: Upload Artifacts to Release
84+
needs:
85+
- create_release
86+
- create_artifacts
87+
runs-on: ubuntu-24.04
88+
permissions:
89+
contents: write
90+
steps:
91+
- name: Download distribution artifacts
92+
uses: actions/[email protected]
93+
with:
94+
pattern: dist-*
95+
path: dist/
96+
merge-multiple: true
97+
98+
- name: Upload Release Assets
99+
env:
100+
VERSION: ${{ needs.determine_version.outputs.release_version }}
101+
run: |
102+
gh release upload "$VERSION" \
103+
dist/${{ needs.create_artifacts.outputs.sdist }} \
104+
dist/${{ needs.create_artifacts.outputs.py3_wheel }} \
105+
dist/${{ needs.create_artifacts.outputs.py2_wheel }}

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ the minified code may only run with Python 3.12.
1515
### Added
1616
- Python 3.14 support (work in progress), including:
1717
+ PEP 750 Template strings (t-strings)
18-
+ Exception handling without parentheses
19-
+ PEP 649 Deferred annotation evaluation
2018

2119
## [3.0.0] - 2025-08-13
2220

0 commit comments

Comments
 (0)