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+ - " v*.*.*"
20+
21+ jobs :
22+ build-pypi-distribs :
23+ name : Build and publish library to PyPI
24+ runs-on : ubuntu-24.04
25+
26+ steps :
27+ - uses : actions/checkout@v4
28+ - name : Set up Python
29+ uses : actions/setup-python@v5
30+ with :
31+ python-version : 3.12
32+
33+ - name : Install pypa/build and twine
34+ run : python -m pip install --user --upgrade build twine pkginfo flot
35+
36+ - name : Build a binary wheel and a source tarball
37+ run : python -m flot --pyproject pyproject.toml --wheel --sdist
38+
39+ - name : Validate wheel and sdis for Pypi
40+ run : python -m twine check dist/*
41+
42+ - name : Upload built archives
43+ uses : actions/upload-artifact@v4
44+ with :
45+ name : pypi_archives
46+ path : dist/*
47+
48+
49+ create-gh-release :
50+ name : Create GH release
51+ needs :
52+ - build-pypi-distribs
53+ runs-on : ubuntu-24.04
54+
55+ steps :
56+ - name : Download built archives
57+ uses : actions/download-artifact@v4
58+ with :
59+ name : pypi_archives
60+ path : dist
61+
62+ - name : Create GH release
63+ uses : softprops/action-gh-release@v2
64+ with :
65+ draft : true
66+ files : dist/*
67+
68+
69+ create-pypi-release :
70+ name : Create PyPI release
71+ needs :
72+ - create-gh-release
73+ runs-on : ubuntu-24.04
74+ environment : pypi-publish
75+ permissions :
76+ id-token : write
77+
78+ steps :
79+ - name : Download built archives
80+ uses : actions/download-artifact@v4
81+ with :
82+ name : pypi_archives
83+ path : dist
84+
85+ - name : Publish to PyPI
86+ if : startsWith(github.ref, 'refs/tags')
87+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments