1+ name : Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch
2+
3+
4+ # This is executed automatically on a tag in the main branch
5+
6+ # Summary of the steps:
7+ # - build wheels and sdist
8+ # - upload wheels and sdist to PyPI
9+ # - create gh-release and upload wheels and dists there
10+ # TODO: smoke test wheels and sdist
11+ # TODO: add changelog to release text body
12+
13+ # WARNING: this is designed only for packages building as pure Python wheels
14+
15+ on :
16+ workflow_dispatch :
17+ push :
18+ tags :
19+ - " commoncode-v*.*.*"
20+
21+ jobs :
22+ build-pypi-distribs :
23+ permissions :
24+ contents : read # to fetch code (actions/checkout)
25+
26+ name : Build and publish library to PyPI
27+ runs-on : ubuntu-24.04
28+
29+ steps :
30+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
31+ with :
32+ persist-credentials : false
33+ - name : Set up Python
34+ uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
35+ with :
36+ python-version : 3.14
37+
38+ - name : Install pypa/build and twine
39+ run : python -m pip install --user --upgrade build twine pkginfo flot
40+
41+ - name : Install requirements then build main and mini wheel
42+ run : etc/release/commoncode-create-pypi-wheel-and-sdist.sh
43+
44+ - name : Upload built archives
45+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
46+ with :
47+ name : pypi_archives
48+ path : dist/*
49+
50+
51+ create-gh-release :
52+ permissions :
53+ contents : write
54+
55+ name : Create GH release
56+ needs :
57+ - build-pypi-distribs
58+ runs-on : ubuntu-24.04
59+
60+ steps :
61+ - name : Download built archives
62+ uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
63+ with :
64+ name : pypi_archives
65+ path : dist
66+
67+ - name : Create GH release
68+ uses : softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
69+ with :
70+ draft : true
71+ files : dist/*
72+
73+
74+ create-pypi-release :
75+ name : Create PyPI release
76+ needs :
77+ - create-gh-release
78+ runs-on : ubuntu-24.04
79+ environment : pypi-publish
80+ permissions :
81+ id-token : write
82+
83+ steps :
84+ - name : Download built archives
85+ uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
86+ with :
87+ name : pypi_archives
88+ path : dist
89+
90+ - name : Publish to PyPI
91+ if : startsWith(github.ref, 'refs/tags')
92+ uses : pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
0 commit comments