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