Skip to content

Commit 5dae104

Browse files
committed
Refactor release workflow
1 parent e8ffe00 commit 5dae104

File tree

3 files changed

+266
-294
lines changed

3 files changed

+266
-294
lines changed

.github/workflows/release.yaml

Lines changed: 7 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -13,129 +13,16 @@ permissions:
1313

1414
jobs:
1515

16-
package_python3:
17-
name: Create sdist and Python 3 Wheel
18-
runs-on: ubuntu-24.04
19-
outputs:
20-
sdist: ${{ steps.package.outputs.sdist }}
21-
wheel: ${{ steps.package.outputs.wheel }}
22-
container:
23-
image: danielflook/python-minifier-build:python3.14-2025-08-21
24-
permissions:
25-
contents: read
26-
steps:
27-
- name: Checkout
28-
uses: actions/[email protected]
29-
with:
30-
fetch-depth: 1
31-
show-progress: false
32-
persist-credentials: false
33-
34-
- name: Set version statically
35-
env:
36-
VERSION: ${{ github.event.release.tag_name }}
37-
run: |
38-
sed -i "s/setup_requires=.*/version='$VERSION',/; s/use_scm_version=.*//" setup.py
39-
echo "Version: $VERSION"
40-
41-
- name: Build distribution packages
42-
id: package
43-
run: |
44-
pip3 install --upgrade build
45-
python3 -m build
46-
47-
echo "sdist=$(find dist -name '*.tar.gz' -printf "%f\n")" >> "$GITHUB_OUTPUT"
48-
echo "wheel=$(find dist -name '*-py3-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT"
49-
50-
- name: Upload sdist artifact
51-
uses: actions/[email protected]
52-
with:
53-
name: dist-sdist
54-
path: dist/${{ steps.package.outputs.sdist }}
55-
if-no-files-found: error
56-
57-
- name: Upload Python 3 wheel artifact
58-
uses: actions/[email protected]
59-
with:
60-
name: dist-py3-wheel
61-
path: dist/${{ steps.package.outputs.wheel }}
62-
if-no-files-found: error
63-
64-
package_python2:
65-
name: Create Python 2 Wheel
66-
runs-on: ubuntu-24.04
67-
needs: [package_python3]
68-
outputs:
69-
wheel: ${{ steps.package.outputs.wheel }}
70-
container:
71-
image: danielflook/python-minifier-build:python2.7-2025-08-21
72-
steps:
73-
- name: Download source distribution artifact
74-
uses: actions/[email protected]
75-
with:
76-
name: dist-sdist
77-
path: dist/
78-
79-
- name: Build Python 2 wheel
80-
id: package
81-
env:
82-
PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }}
83-
run: |
84-
dnf install -y findutils
85-
pip install --upgrade wheel
86-
pip wheel dist/"$PYTHON3_SDIST" -w dist
87-
echo "wheel=$(find dist -name '*-py2-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT"
88-
89-
- name: Upload Python 2 wheel artifact
90-
uses: actions/[email protected]
91-
with:
92-
name: dist-py2-wheel
93-
path: dist/${{ steps.package.outputs.wheel }}
94-
if-no-files-found: error
95-
96-
documentation:
97-
name: Test Documentation
98-
runs-on: ubuntu-24.04
99-
needs: [package_python3]
100-
container:
101-
image: danielflook/python-minifier-build:python3.14-2025-08-21
102-
permissions:
103-
contents: read
104-
steps:
105-
- uses: actions/[email protected]
106-
with:
107-
name: dist-sdist
108-
path: dist/
109-
110-
- name: Install package
111-
env:
112-
PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }}
113-
run: |
114-
pip3 install dist/"$PYTHON3_SDIST"
115-
pyminify --version
116-
117-
- name: Checkout
118-
uses: actions/[email protected]
119-
with:
120-
fetch-depth: 1
121-
show-progress: false
122-
persist-credentials: false
123-
124-
- name: Build documentation
125-
run: |
126-
pip3 install sphinx sphinxcontrib-programoutput sphinx_rtd_theme
127-
sphinx-build docs/source /tmp/build
128-
129-
- name: Upload documentation artifact
130-
uses: actions/[email protected]
131-
with:
132-
path: /tmp/build
16+
create_artifacts:
17+
name: Create Artifacts
18+
uses: ./.github/workflows/release_artifacts.yaml
19+
with:
20+
release_version: ${{ github.event.release.tag_name }}
13321

13422
publish-to-pypi:
13523
name: Publish to PyPI
13624
needs:
137-
- package_python3
138-
- package_python2
25+
- create_artifacts
13926
runs-on: ubuntu-24.04
14027
permissions:
14128
id-token: write
@@ -159,7 +46,7 @@ jobs:
15946
publish-docs:
16047
name: Publish Documentation
16148
needs:
162-
- documentation
49+
- create_artifacts
16350
runs-on: ubuntu-24.04
16451
permissions:
16552
pages: write
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
name: Create Release Artifacts
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release_version:
7+
description: The version to set in setup.py
8+
required: true
9+
type: string
10+
outputs:
11+
sdist:
12+
description: The source distribution filename
13+
value: ${{ jobs.package_python3.outputs.sdist }}
14+
py3_wheel:
15+
description: The Python 3 wheel filename
16+
value: ${{ jobs.package_python3.outputs.wheel }}
17+
py2_wheel:
18+
description: The Python 2 wheel filename
19+
value: ${{ jobs.package_python2.outputs.wheel }}
20+
21+
jobs:
22+
23+
package_python3:
24+
name: Create sdist and Python 3 Wheel
25+
runs-on: ubuntu-24.04
26+
outputs:
27+
sdist: ${{ steps.package.outputs.sdist }}
28+
wheel: ${{ steps.package.outputs.wheel }}
29+
container:
30+
image: danielflook/python-minifier-build:python3.14-2025-08-21
31+
permissions:
32+
contents: read
33+
steps:
34+
- name: Checkout
35+
uses: actions/[email protected]
36+
with:
37+
fetch-depth: 1
38+
show-progress: false
39+
persist-credentials: false
40+
41+
- name: Set version statically
42+
env:
43+
VERSION: ${{ inputs.release_version }}
44+
run: |
45+
sed -i "s/setup_requires=.*/version='$VERSION',/; s/use_scm_version=.*//" setup.py
46+
echo "Version: $VERSION"
47+
48+
- name: Build distribution packages
49+
id: package
50+
run: |
51+
pip3 install --upgrade build
52+
python3 -m build
53+
54+
echo "sdist=$(find dist -name '*.tar.gz' -printf "%f\n")" >> "$GITHUB_OUTPUT"
55+
echo "wheel=$(find dist -name '*-py3-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT"
56+
57+
- name: Upload sdist artifact
58+
uses: actions/[email protected]
59+
with:
60+
name: dist-sdist
61+
path: dist/${{ steps.package.outputs.sdist }}
62+
if-no-files-found: error
63+
64+
- name: Upload Python 3 wheel artifact
65+
uses: actions/[email protected]
66+
with:
67+
name: dist-py3-wheel
68+
path: dist/${{ steps.package.outputs.wheel }}
69+
if-no-files-found: error
70+
71+
package_python2:
72+
name: Create Python 2 Wheel
73+
runs-on: ubuntu-24.04
74+
needs: [package_python3]
75+
outputs:
76+
wheel: ${{ steps.package.outputs.wheel }}
77+
container:
78+
image: danielflook/python-minifier-build:python2.7-2025-08-21
79+
steps:
80+
- name: Download source distribution artifact
81+
uses: actions/[email protected]
82+
with:
83+
name: dist-sdist
84+
path: dist/
85+
86+
- name: Build Python 2 wheel
87+
id: package
88+
env:
89+
PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }}
90+
run: |
91+
dnf install -y findutils
92+
pip install --upgrade wheel
93+
pip wheel dist/"$PYTHON3_SDIST" -w dist
94+
echo "wheel=$(find dist -name '*-py2-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT"
95+
96+
- name: Upload Python 2 wheel artifact
97+
uses: actions/[email protected]
98+
with:
99+
name: dist-py2-wheel
100+
path: dist/${{ steps.package.outputs.wheel }}
101+
if-no-files-found: error
102+
103+
documentation:
104+
name: Build Documentation
105+
runs-on: ubuntu-24.04
106+
needs: [package_python3]
107+
container:
108+
image: danielflook/python-minifier-build:python3.14-2025-08-21
109+
permissions:
110+
contents: read
111+
steps:
112+
- uses: actions/[email protected]
113+
with:
114+
name: dist-sdist
115+
path: dist/
116+
117+
- name: Install package
118+
env:
119+
PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }}
120+
run: |
121+
pip3 install dist/"$PYTHON3_SDIST"
122+
pyminify --version
123+
124+
- name: Checkout
125+
uses: actions/[email protected]
126+
with:
127+
fetch-depth: 1
128+
show-progress: false
129+
persist-credentials: false
130+
131+
- name: Build documentation
132+
run: |
133+
pip3 install sphinx sphinxcontrib-programoutput sphinx_rtd_theme
134+
sphinx-build docs/source /tmp/build
135+
136+
- name: Upload documentation artifact
137+
uses: actions/[email protected]
138+
with:
139+
path: /tmp/build
140+
141+
test_package:
142+
name: Test Package
143+
runs-on: ubuntu-24.04
144+
needs: [package_python2, package_python3]
145+
strategy:
146+
fail-fast: false
147+
matrix:
148+
python: ["2.7", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
149+
package_type: [sdist, wheel]
150+
steps:
151+
- name: Checkout
152+
uses: actions/[email protected]
153+
with:
154+
fetch-depth: 1
155+
show-progress: false
156+
persist-credentials: false
157+
158+
- name: Download distribution artifacts
159+
uses: actions/[email protected]
160+
with:
161+
pattern: dist-*
162+
path: dist/
163+
merge-multiple: true
164+
165+
- name: Test
166+
uses: ./.github/actions/run-in-container
167+
with:
168+
image: danielflook/python-minifier-build:python${{ matrix.python }}-2025-08-21
169+
run: |
170+
if [[ "${{ matrix.package_type }}" == "sdist" ]]; then
171+
pip${{ matrix.python }} install dist/${{needs.package_python3.outputs.sdist}}
172+
elif [[ "${{ matrix.python }}" == "2.7" ]]; then
173+
pip${{ matrix.python }} install dist/${{needs.package_python2.outputs.py2_wheel}}
174+
else
175+
pip${{ matrix.python }} install dist/${{needs.package_python3.outputs.py3_wheel}}
176+
fi
177+
178+
pyminify --version
179+
180+
set -x
181+
cat setup.py | pyminify -
182+
pyminify setup.py > /tmp/out.min.py
183+
pyminify setup.py --output /tmp/out.min.py2
184+
pyminify setup.py src test --in-place
185+
186+
test_typing:
187+
name: Test Typing
188+
runs-on: ubuntu-24.04
189+
needs: [package_python3]
190+
strategy:
191+
matrix:
192+
package_type: [sdist, wheel]
193+
container:
194+
image: danielflook/python-minifier-build:python3.14-2025-08-21
195+
steps:
196+
- name: Download distribution artifacts
197+
uses: actions/[email protected]
198+
with:
199+
pattern: dist-*
200+
path: dist/
201+
merge-multiple: true
202+
203+
- name: Install package
204+
env:
205+
PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }}
206+
PYTHON3_WHEEL: ${{ needs.package_python3.outputs.py3_wheel }}
207+
run: |
208+
if [[ "${{ matrix.package_type }}" == "sdist" ]]; then
209+
pip3.14 install "dist/$PYTHON3_SDIST"
210+
else
211+
pip3.14 install "dist/$PYTHON3_WHEEL"
212+
fi
213+
214+
- name: Checkout
215+
uses: actions/[email protected]
216+
with:
217+
fetch-depth: 1
218+
show-progress: false
219+
persist-credentials: false
220+
221+
- name: Test typing
222+
run: |
223+
pip3.14 install 'mypy<1.12.0' types-setuptools
224+
mypy --strict typing_test/test_typing.py
225+
226+
if mypy --strict typing_test/test_badtyping.py; then
227+
echo "Bad types weren't detected"
228+
exit 1
229+
fi
230+
231+
stubtest python_minifier --allowlist typing_test/stubtest-allowlist.txt

0 commit comments

Comments
 (0)