1- name : Publish Python 🐍 distribution 📦 to PyPI and deploy docs 📖
1+ name : Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
22
3- on :
4- push :
5- branches :
6- - main
7- release :
8- types :
9- - published
3+ on : push
104
115jobs :
126
@@ -37,33 +31,78 @@ jobs:
3731 with :
3832 name : python-package-distributions
3933 path : dist/
40-
41- # # Publication à PyPi
34+
35+ # # Publication to PyPi
4236 publish-to-pypi :
43- name : Publish to PyPI 📦
44- if : startsWith(github.ref, 'refs/tags/')
37+ name : >-
38+ Publish Python 🐍 distribution 📦 to PyPI
39+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
4540 needs :
4641 - build
4742 runs-on : ubuntu-latest
4843 environment :
4944 name : pypi
5045 url : https://pypi.org/p/hestonpy
5146 permissions :
52- id-token : write
47+ id-token : write # IMPORTANT: mandatory for trusted publishing
5348 steps :
5449 - name : Download all the dists
5550 uses : actions/download-artifact@v4
5651 with :
5752 name : python-package-distributions
5853 path : dist/
59- - name : Publish to PyPI
54+ - name : Publish distribution 📦 to PyPI
6055 uses : pypa/gh-action-pypi-publish@release/v1
6156
62- # # Déploiement de la documentation 📖
57+ # # GitHub
58+ github-release :
59+ name : >-
60+ Sign the Python 🐍 distribution 📦 with Sigstore
61+ and upload them to GitHub Release
62+ needs :
63+ - publish-to-pypi
64+ runs-on : ubuntu-latest
65+
66+ permissions :
67+ contents : write # IMPORTANT: mandatory for making GitHub Releases
68+ id-token : write # IMPORTANT: mandatory for sigstore
69+
70+ steps :
71+ - name : Download all the dists
72+ uses : actions/download-artifact@v4
73+ with :
74+ name : python-package-distributions
75+ path : dist/
76+ - name : Sign the dists with Sigstore
77+ uses : sigstore/gh-action-sigstore-python@v3.0.0
78+ with :
79+ inputs : >-
80+ ./dist/*.tar.gz
81+ ./dist/*.whl
82+ - name : Create GitHub Release
83+ env :
84+ GITHUB_TOKEN : ${{ github.token }}
85+ run : >-
86+ gh release create
87+ "$GITHUB_REF_NAME"
88+ --repo "$GITHUB_REPOSITORY"
89+ --notes ""
90+ - name : Upload artifact signatures to GitHub Release
91+ env :
92+ GITHUB_TOKEN : ${{ github.token }}
93+ # Upload to GitHub Release using the `gh` CLI.
94+ # `dist/` contains the built packages, and the
95+ # sigstore-produced signatures and certificates.
96+ run : >-
97+ gh release upload
98+ "$GITHUB_REF_NAME" dist/**
99+ --repo "$GITHUB_REPOSITORY"
100+
101+ # # Déploiement de la documentation après publication sur PyPI
63102 deploy-docs :
64- name : Deploy Sphinx Docs 📖
103+ name : " Build and Deploy Documentation 📖 "
65104 needs :
66- - publish-to-pypi
105+ - publish-to-pypi
67106 runs-on : ubuntu-latest
68107
69108 steps :
@@ -73,12 +112,13 @@ jobs:
73112 - name : Set up Python
74113 uses : actions/setup-python@v4
75114 with :
76- python-version : " 3.10"
115+ python-version : ' 3.10'
77116
78117 - name : Install dependencies
79118 run : |
80119 python -m pip install --upgrade pip
81- pip install pydata-sphinx-theme sphinx
120+ pip install pydata-sphinx-theme
121+ pip install sphinx
82122
83123 - name : Build Sphinx documentation
84124 run : |
@@ -91,3 +131,29 @@ jobs:
91131 github_token : ${{ secrets.GITHUB_TOKEN }}
92132 publish_dir : doc/_build/html
93133 branch : gh-pages
134+
135+ # # Publication to TestPyPi
136+ publish-to-testpypi :
137+ name : Publish Python 🐍 distribution 📦 to TestPyPI
138+ needs :
139+ - build
140+ runs-on : ubuntu-latest
141+
142+ environment :
143+ name : testpypi
144+ url : https://test.pypi.org/project/hestonpy/
145+
146+ permissions :
147+ id-token : write # IMPORTANT: mandatory for trusted publishing
148+
149+ steps :
150+ - name : Download all the dists
151+ uses : actions/download-artifact@v4
152+ with :
153+ name : python-package-distributions
154+ path : dist/
155+ - name : Publish distribution 📦 to TestPyPI
156+ uses : pypa/gh-action-pypi-publish@release/v1
157+ with :
158+ repository-url : https://test.pypi.org/legacy/
159+
0 commit comments