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