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