1+ name : Publish to PyPI
2+ on :
3+ push :
4+ branches : [main]
5+ tags : ' *'
6+ pull_request :
7+
8+ jobs :
9+ build :
10+ name : Build distribution
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v4
15+ - name : Set up Python
16+ uses : actions/setup-python@v5
17+ with :
18+ python-version : " 3.13"
19+ - name : Install pypa/build
20+ run : >-
21+ python3 -m
22+ pip install
23+ build
24+ --user
25+
26+ # If the event that triggered this workflow is a push of a tag, then build with
27+ # the version of that tag.
28+ - name : Build a binary wheel and a source tarball for tag
29+ run : BUILD_VERSION=${{ github.ref_name }} python3 -m build
30+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
31+ # The event that trigged this workflow is not a tag, so build without specifying the version.
32+ - name : Build a binary wheel and a source tarball
33+ run : python3 -m build
34+ if : " !startsWith(github.ref, 'refs/tags/')"
35+
36+ - name : Store the distribution packages
37+ uses : actions/upload-artifact@v4
38+ with :
39+ name : python-package-distributions
40+ path : dist/
41+
42+ pypi-publish :
43+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
44+ needs : [build]
45+ name : Upload release to PyPI
46+ runs-on : ubuntu-latest
47+ environment :
48+ name : pypi
49+ url : https://pypi.org/p/wagtail-thumbnail-choice-block
50+ permissions :
51+ id-token : write
52+ steps :
53+ - name : Download all the dists
54+ uses : actions/download-artifact@v4
55+ with :
56+ name : python-package-distributions
57+ path : dist/
58+ - name : Publish distribution to PyPI
59+ uses : pypa/gh-action-pypi-publish@release/v1
60+
61+ github-release :
62+ name : >-
63+ Sign the Python 🐍 distribution 📦 with Sigstore
64+ and upload them to GitHub Release
65+ needs :
66+ - pypi-publish
67+ runs-on : ubuntu-latest
68+
69+ permissions :
70+ contents : write # IMPORTANT: mandatory for making GitHub Releases
71+ id-token : write # IMPORTANT: mandatory for sigstore
72+
73+ steps :
74+ - name : Download all the dists
75+ uses : actions/download-artifact@v4
76+ with :
77+ name : python-package-distributions
78+ path : dist/
79+ - name : Sign the dists with Sigstore
80+ uses : sigstore/gh-action-sigstore-python@v3
81+ with :
82+ inputs : >-
83+ ./dist/*.tar.gz
84+ ./dist/*.whl
85+ - name : Create GitHub Release
86+ env :
87+ GITHUB_TOKEN : ${{ github.token }}
88+ run : >-
89+ gh release create
90+ '${{ github.ref_name }}'
91+ --repo '${{ github.repository }}'
92+ --generate-notes
93+ - name : Upload artifact signatures to GitHub Release
94+ env :
95+ GITHUB_TOKEN : ${{ github.token }}
96+ # Upload to GitHub Release using the `gh` CLI.
97+ # `dist/` contains the built packages, and the
98+ # sigstore-produced signatures and certificates.
99+ run : >-
100+ gh release upload
101+ '${{ github.ref_name }}' dist/**
102+ --repo '${{ github.repository }}'
0 commit comments