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