Skip to content

Commit 83138d6

Browse files
committed
Add new GH Action to automate release
This workflow builds app and PyPI archives and then upload to PyPI and creates a GH release Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent d57b91b commit 83138d6

File tree

1 file changed

+388
-0
lines changed

1 file changed

+388
-0
lines changed
Lines changed: 388 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,388 @@
1+
name: Create ScanCode release archives, then test and publish to GH and PyPI
2+
3+
# This is executed automatically on a tag
4+
5+
# Summary of the steps:
6+
# - build wheel and sdist for main and same for mini flavor
7+
# - then upload all wheels and sdist to PyPI
8+
# - build release app archives, one for each of linux, windows, macos on Python 3.8
9+
# - then create gh-release and upload app archives to release
10+
# TODO: for each of linux, windows, macos: smoke test wheel, sdist and release archives
11+
# TODO: add changelog to release text body
12+
13+
14+
on:
15+
workflow_dispatch:
16+
push:
17+
tags:
18+
- "v*.*.*"
19+
20+
jobs:
21+
22+
build_scancode_for_pypi:
23+
name: Build ScanCode PyPI archives
24+
runs-on: ubuntu-20.04
25+
26+
defaults:
27+
run:
28+
shell: bash
29+
strategy:
30+
fail-fast: false
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: 3.8
39+
40+
- name: Install requirements and prepare index
41+
run: |
42+
./configure --dev
43+
./scancode --reindex-licenses
44+
45+
46+
- name: Build main wheel
47+
run: |
48+
venv/bin/python setup.py --quiet bdist_wheel
49+
venv/bin/twine check dist/*
50+
51+
- name: Collect built main wheel
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: main_wheel
55+
path: dist/*
56+
57+
- name: Build main sdist
58+
run: |
59+
rm -rf dist
60+
venv/bin/python setup.py --quiet sdist
61+
venv/bin/twine check dist/*
62+
63+
- name: Collect built main sdist
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: main_sdist
67+
path: dist/*
68+
69+
70+
build_scancode_for_pypi_mini:
71+
name: Build ScanCode PyPI archives mini
72+
runs-on: ubuntu-20.04
73+
74+
defaults:
75+
run:
76+
shell: bash
77+
strategy:
78+
fail-fast: false
79+
80+
steps:
81+
- uses: actions/checkout@v2
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v1
85+
with:
86+
python-version: 3.8
87+
88+
- name: Install requirements and prepare index
89+
run: |
90+
./configure --dev
91+
./scancode --reindex-licenses
92+
93+
- name: Build mini wheel
94+
run: |
95+
rm -rf build dist
96+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
97+
cp setup-mini.cfg setup.cfg
98+
venv/bin/python setup.py --quiet bdist_wheel
99+
venv/bin/twine check dist/*
100+
101+
- name: Collect built mini wheel
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: mini_wheel
105+
path: dist/*
106+
107+
- name: Build mini sdist
108+
run: |
109+
rm -rf build dist
110+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
111+
cp setup-mini.cfg setup.cfg
112+
venv/bin/python setup.py --quiet sdist
113+
venv/bin/twine check dist/*
114+
115+
- name: Collect built mini sdist
116+
uses: actions/upload-artifact@v3
117+
with:
118+
name: mini_sdist
119+
path: dist/*
120+
121+
122+
build_scancode_for_release_linux:
123+
name: Build ScanCode Release archives for linux
124+
runs-on: ubuntu-20.04
125+
126+
defaults:
127+
run:
128+
shell: bash
129+
strategy:
130+
fail-fast: false
131+
132+
steps:
133+
- uses: actions/checkout@v2
134+
135+
- name: Set up Python
136+
uses: actions/setup-python@v1
137+
with:
138+
python-version: 3.8
139+
140+
- name: Install requirements and prepare index
141+
run: |
142+
./configure --dev
143+
./scancode --reindex-licenses
144+
145+
- name: Build linux app archive
146+
run: |
147+
source venv/bin/activate
148+
formats=xztar
149+
operating_system=linux
150+
python_dot_version=3.8
151+
python_version=38
152+
echo -n "python$python_dot_version" > PYTHON_EXECUTABLE
153+
rm -rf thirdparty build dist
154+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
155+
mkdir -p thirdparty
156+
venv/bin/python etc/scripts/fetch_thirdparty.py \
157+
--requirements=requirements.txt \
158+
--dest=thirdparty \
159+
--python-version=$python_version \
160+
--operating-system=$operating_system \
161+
--wheels
162+
venv/bin/python setup.py --quiet sdist --formats=$formats
163+
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system
164+
165+
- name: Collect built linux app
166+
uses: actions/upload-artifact@v3
167+
with:
168+
name: linux_app
169+
path: dist/*
170+
171+
172+
build_scancode_for_release_mac:
173+
name: Build ScanCode Release archives for mac
174+
runs-on: ubuntu-20.04
175+
176+
defaults:
177+
run:
178+
shell: bash
179+
strategy:
180+
fail-fast: false
181+
182+
steps:
183+
- uses: actions/checkout@v2
184+
185+
- name: Set up Python
186+
uses: actions/setup-python@v1
187+
with:
188+
python-version: 3.8
189+
190+
- name: Install requirements and prepare index
191+
run: |
192+
./configure --dev
193+
./scancode --reindex-licenses
194+
195+
196+
- name: Build mac app archive
197+
run: |
198+
source venv/bin/activate
199+
formats=xztar
200+
operating_system=macos
201+
python_dot_version=3.8
202+
python_version=38
203+
echo -n "python$python_dot_version" > PYTHON_EXECUTABLE
204+
rm -rf thirdparty build dist
205+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
206+
mkdir -p thirdparty
207+
venv/bin/python etc/scripts/fetch_thirdparty.py \
208+
--requirements=requirements.txt \
209+
--dest=thirdparty \
210+
--python-version=$python_version \
211+
--operating-system=$operating_system \
212+
--wheels
213+
venv/bin/python setup.py --quiet sdist --formats=$formats
214+
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system
215+
216+
- name: Collect built mac app
217+
uses: actions/upload-artifact@v3
218+
with:
219+
name: macos_app
220+
path: dist/*
221+
222+
223+
build_scancode_for_release_win:
224+
name: Build ScanCode Release archives for windows
225+
runs-on: ubuntu-20.04
226+
227+
defaults:
228+
run:
229+
shell: bash
230+
strategy:
231+
fail-fast: false
232+
233+
steps:
234+
- uses: actions/checkout@v2
235+
236+
- name: Set up Python
237+
uses: actions/setup-python@v1
238+
with:
239+
python-version: 3.8
240+
241+
- name: Install requirements and prepare index
242+
run: |
243+
./configure --dev
244+
./scancode --reindex-licenses
245+
246+
- name: Build windows app archive
247+
run: |
248+
source venv/bin/activate
249+
formats=zip
250+
operating_system=windows
251+
python_dot_version=3.8
252+
python_version=38
253+
echo -n "py -$python_dot_version" > PYTHON_EXECUTABLE
254+
rm -rf thirdparty build dist
255+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
256+
mkdir -p thirdparty
257+
venv/bin/python etc/scripts/fetch_thirdparty.py \
258+
--requirements=requirements.txt \
259+
--dest=thirdparty \
260+
--python-version=$python_version \
261+
--operating-system=$operating_system \
262+
--wheels
263+
venv/bin/python setup.py --quiet sdist --formats=$formats
264+
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system
265+
266+
- name: Collect built windows app
267+
uses: actions/upload-artifact@v3
268+
with:
269+
name: windows_app
270+
path: dist/*
271+
272+
build_scancode_for_release_source:
273+
name: Build ScanCode Release archives source
274+
runs-on: ubuntu-20.04
275+
276+
defaults:
277+
run:
278+
shell: bash
279+
strategy:
280+
fail-fast: false
281+
282+
steps:
283+
- uses: actions/checkout@v2
284+
285+
- name: Set up Python
286+
uses: actions/setup-python@v1
287+
with:
288+
python-version: 3.8
289+
290+
- name: Install requirements and prepare index
291+
run: |
292+
./configure --dev
293+
294+
- name: Build source archive with deps
295+
run: |
296+
source venv/bin/activate
297+
formats=xztar
298+
rm -rf thirdparty build dist src/licensedcode/data/cache
299+
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
300+
mkdir -p thirdparty
301+
venv/bin/python etc/scripts/fetch_thirdparty.py \
302+
--requirements=requirements.txt \
303+
--dest=thirdparty \
304+
--sdists
305+
venv/bin/python setup.py --quiet sdist --formats=$formats
306+
venv/bin/python etc/release/scancode_rename_archives.py dist/ _sources
307+
308+
- name: Collect built source app tarball
309+
uses: actions/upload-artifact@v3
310+
with:
311+
name: source_app
312+
path: dist/*
313+
314+
315+
publish_to_pypi:
316+
name: Publish to PyPI
317+
needs: [build_scancode_for_pypi, build_scancode_for_pypi_mini]
318+
runs-on: ubuntu-20.04
319+
defaults:
320+
run:
321+
shell: bash
322+
strategy:
323+
fail-fast: false
324+
matrix:
325+
dist_names: [main_wheel, main_sdist, mini_wheel, mini_sdist]
326+
327+
steps:
328+
- name: Set up Python
329+
uses: actions/setup-python@v1
330+
with:
331+
python-version: 3.8
332+
333+
- name: Download a single artifact
334+
uses: actions/download-artifact@v3
335+
with:
336+
name: ${{ matrix.dist_names }}
337+
path: dist
338+
339+
- name: Publish distributions to PyPI
340+
uses: pypa/gh-action-pypi-publish@master
341+
with:
342+
password: ${{ secrets.PYPI_API_TOKEN }}
343+
344+
345+
publish_to_gh_release:
346+
name: Publish to GH Release
347+
needs:
348+
- build_scancode_for_release_linux
349+
- build_scancode_for_release_win
350+
- build_scancode_for_release_mac
351+
- build_scancode_for_release_source
352+
runs-on: ubuntu-20.04
353+
defaults:
354+
run:
355+
shell: bash
356+
strategy:
357+
fail-fast: false
358+
359+
steps:
360+
- name: Download a single artifact source_app
361+
uses: actions/download-artifact@v3
362+
with:
363+
name: source_app
364+
path: dist
365+
366+
- name: Download a single artifact macos_app
367+
uses: actions/download-artifact@v3
368+
with:
369+
name: macos_app
370+
path: dist
371+
372+
- name: Download a single artifact linux_app
373+
uses: actions/download-artifact@v3
374+
with:
375+
name: linux_app
376+
path: dist
377+
378+
- name: Download a single artifact windows_app
379+
uses: actions/download-artifact@v3
380+
with:
381+
name: windows_app
382+
path: dist
383+
384+
- name: Create release and publish archives
385+
uses: softprops/action-gh-release@v1
386+
with:
387+
draft: true
388+
files: dist/*

0 commit comments

Comments
 (0)