@@ -14,56 +14,100 @@ jobs:
14
14
outputs :
15
15
publish_to_pypi : ${{ steps.version_check.outputs.publish_to_pypi }}
16
16
publish_to_testpypi : ${{ steps.version_check.outputs.publish_to_testpypi }}
17
+ version : ${{ steps.version_check.outputs.version }}
17
18
steps :
18
- - uses : actions/checkout@v4
19
+ - uses : actions/checkout@v4
19
20
20
- - name : Set up Python
21
- uses : actions/setup-python@v5
22
- with :
23
- python-version : ' 3.x'
21
+ - name : Set up Python
22
+ uses : actions/setup-python@v5
23
+ with :
24
+ python-version : ' 3.x'
24
25
25
- - name : Install dependencies for version check
26
- run : |
27
- python -m pip install --upgrade pip
28
- pip install requests
26
+ - name : Install dependencies for version check
27
+ run : |
28
+ python -m pip install --upgrade pip
29
+ pip install requests
29
30
30
- - name : Check version on PyPI or TestPyPI
31
- id : version_check
32
- run : |
33
- python3 check_version.py ${{ github.ref }}
34
- env :
35
- GITHUB_OUTPUT : ${{ github.output }}
31
+ - name : Check version on PyPI or TestPyPI
32
+ id : version_check
33
+ run : |
34
+ python3 check_version.py ${{ github.ref }}
35
+
36
+ env :
37
+ GITHUB_OUTPUT : ${{ github.output }}
36
38
37
39
build-and-publish :
38
40
needs : prepare-and-check
39
41
if : needs.prepare-and-check.outputs.publish_to_pypi == 'true' || needs.prepare-and-check.outputs.publish_to_testpypi == 'true'
40
42
runs-on : ubuntu-latest
41
43
steps :
42
- - uses : actions/checkout@v4
43
- - name : Set up Python
44
- uses : actions/setup-python@v5
45
- with :
46
- python-version : ' 3.x'
47
-
48
- - name : Install build dependencies
49
- run : |
50
- python -m pip install --upgrade pip
51
- pip install setuptools wheel twine
52
-
53
- - name : Build package
54
- run : |
55
- python setup.py sdist bdist_wheel
56
-
57
- - name : Publish to PyPI
58
- if : needs.prepare-and-check.outputs.publish_to_pypi == 'true'
59
- run : twine upload dist/*
60
- env :
61
- TWINE_USERNAME : ${{ secrets.PYPI_USERNAME }}
62
- TWINE_PASSWORD : ${{ secrets.PYPI_PASSWORD }}
63
-
64
- - name : Publish to TestPyPI
65
- if : needs.prepare-and-check.outputs.publish_to_testpypi == 'true'
66
- run : twine upload --repository-url https://test.pypi.org/legacy/ dist/*
67
- env :
68
- TWINE_USERNAME : ${{ secrets.TEST_PYPI_USERNAME }}
69
- TWINE_PASSWORD : ${{ secrets.TEST_PYPI_PASSWORD }}
44
+ - uses : actions/checkout@v4
45
+
46
+ - name : Set up Python
47
+ uses : actions/setup-python@v5
48
+ with :
49
+ python-version : ' 3.x'
50
+
51
+ - name : Install build dependencies
52
+ run : |
53
+ python -m pip install --upgrade pip
54
+ pip install setuptools wheel twine
55
+
56
+ - name : Build package
57
+ run : |
58
+ python setup.py sdist bdist_wheel
59
+
60
+ - name : Upload distribution packages as artifacts
61
+ uses : actions/upload-artifact@v3
62
+ with :
63
+ name : python-package-distributions
64
+ path : dist/*
65
+
66
+ - name : Publish to PyPI
67
+ if : needs.prepare-and-check.outputs.publish_to_pypi == 'true'
68
+ run : twine upload dist/*
69
+ env :
70
+ TWINE_USERNAME : ${{ secrets.PYPI_USERNAME }}
71
+ TWINE_PASSWORD : ${{ secrets.PYPI_PASSWORD }}
72
+
73
+ - name : Publish to TestPyPI
74
+ if : needs.prepare-and-check.outputs.publish_to_testpypi == 'true'
75
+ run : twine upload --repository-url https://test.pypi.org/legacy/ dist/*
76
+ env :
77
+ TWINE_USERNAME : ${{ secrets.TEST_PYPI_USERNAME }}
78
+ TWINE_PASSWORD : ${{ secrets.TEST_PYPI_PASSWORD }}
79
+
80
+ create-release :
81
+ needs : build-and-publish
82
+ if : needs.build-and-publish.outputs.publish_to_pypi == 'true'
83
+ runs-on : ubuntu-latest
84
+ steps :
85
+ - uses : actions/checkout@v4
86
+
87
+ - name : Download distribution packages for release
88
+ uses : actions/download-artifact@v4
89
+ with :
90
+ name : python-package-distributions
91
+ path : dist/
92
+
93
+ - name : Sign the distributions with Sigstore
94
+
95
+ with :
96
+ inputs : ./dist/*.tar.gz ./dist/*.whl
97
+
98
+ - name : Draft Release
99
+ id : draft_release
100
+ uses : release-drafter/release-drafter@v6
101
+ env :
102
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103
+
104
+ - name : Create GitHub Release
105
+ uses : actions/create-release@v1
106
+ env :
107
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108
+ with :
109
+ tag_name : v${{ needs.prepare-and-check.outputs.version }}
110
+ release_name : Release v${{ needs.prepare-and-check.outputs.version }}
111
+ body : ${{ steps.draft_release.outputs.body }}
112
+ draft : false
113
+ prerelease : false
0 commit comments