1
+ name : Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
2
+
3
+ on :
4
+ create :
5
+ tags :
6
+ - ' v*'
7
+ push :
8
+ branches : [ "master", "dev" ]
9
+
10
+ jobs :
11
+ publish-to-pypi :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+
15
+ - uses : actions/checkout@master
16
+
17
+ - name : Set up Python 3.11
18
+ uses : actions/setup-python@v1
19
+ with :
20
+ python-version : 3.11
21
+
22
+ - name : Install build
23
+ run : >-
24
+ pip install -r requirements.txt
25
+ python setup.py sdist
26
+
27
+ - name : Publish distribution 📦 to Test PyPI
28
+ uses : pypa/gh-action-pypi-publish@master
29
+ with :
30
+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
31
+ repository_url : https://test.pypi.org/legacy/
32
+
33
+ - name : Publish distribution 📦 to Test PyPI
34
+ if : startsWith(github.ref, 'refs/dev')
35
+ uses : pypa/gh-action-pypi-publish@master
36
+ with :
37
+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
38
+ repository_url : https://test.pypi.org/legacy/
39
+ skip_existing : true
40
+
41
+ - name : Publish distribution 📦 to PyPI
42
+ if : startsWith(github.ref, 'refs/tags/')
43
+ uses : pypa/gh-action-pypi-publish@master
44
+ with :
45
+ password : ${{ secrets.PYPI_API_TOKEN }}
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
+ permissions :
55
+ contents : write
56
+ id-token : write
57
+ steps :
58
+ - name : Download all the dists
59
+ uses : actions/download-artifact@v3
60
+ with :
61
+ name : python-package-distributions
62
+ path : dist/
63
+ - name : Sign the dists with Sigstore
64
+
65
+ with :
66
+ inputs : >-
67
+ ./dist/*.tar.gz
68
+ ./dist/*.whl
69
+ - name : Create GitHub Release
70
+ env :
71
+ GITHUB_TOKEN : ${{ github.token }}
72
+ run : >-
73
+ gh release create
74
+ '${{ github.ref_name }}'
75
+ --repo '${{ github.repository }}'
76
+ --notes ""
77
+ - name : Upload artifact signatures to GitHub Release
78
+ env :
79
+ GITHUB_TOKEN : ${{ github.token }}
80
+ run : >-
81
+ gh release upload
82
+ '${{ github.ref_name }}' dist/**
83
+ --repo '${{ github.repository }}'
0 commit comments