1
1
# From: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
2
name : Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
3
- on : push
3
+ on :
4
+ workflow_dispatch :
5
+ push :
6
+ tags :
7
+ - ' *'
4
8
jobs :
5
9
build :
6
10
name : Build Python 📦
@@ -20,86 +24,114 @@ jobs:
20
24
with :
21
25
name : python-package-distributions
22
26
path : dist/
27
+ test :
28
+ name : Test Python 📦
29
+ needs :
30
+ - build
31
+ runs-on : ubuntu-latest
32
+ steps :
33
+ - name : Download all the dists
34
+ uses : actions/download-artifact@v4
35
+ with :
36
+ name : python-package-distributions
37
+ path : dist
38
+ - uses : actions/checkout@v4
39
+ - uses : actions/setup-python@v5
40
+ with :
41
+ python-version : 3.12
42
+ cache : ' pip'
43
+ - name : Install
44
+ run : |
45
+ find dist -name '*.whl' -exec pip install {} \;
46
+ pip install pytest
47
+ - name : Test Gymnasium
48
+ run : pytest test/test_gymnasium.py
49
+ - name : Test PettingZoo
50
+ run : pytest test/test_pettingzoo.py
51
+ - name : Install torchrl
52
+ run : find dist -name '*.whl' -exec pip install {}[torchrl] \;
53
+ - name : Test TorchRL
54
+ run : pytest test/test_torchrl.py
23
55
publish-to-testpypi :
24
56
name : Publish Python 🐍 distribution 📦 to TestPyPI
25
57
needs :
26
- - build
58
+ - test
27
59
runs-on : ubuntu-latest
28
60
environment :
29
61
name : testpypi
30
62
url : https://test.pypi.org/p/navground-learning
31
63
permissions :
32
64
id-token : write # IMPORTANT: mandatory for trusted publishing
33
65
steps :
34
- - name : Download all the dists
35
- uses : actions/download-artifact@v4
36
- with :
37
- name : python-package-distributions
38
- path : dist/
39
- - name : Publish distribution 📦 to TestPyPI
40
- uses : pypa/gh-action-pypi-publish@release/v1
41
- with :
42
- repository-url : https://test.pypi.org/legacy/
43
- skip-existing : true
66
+ - name : Download all the dists
67
+ uses : actions/download-artifact@v4
68
+ with :
69
+ name : python-package-distributions
70
+ path : dist/
71
+ - name : Publish distribution 📦 to TestPyPI
72
+ uses : pypa/gh-action-pypi-publish@release/v1
73
+ with :
74
+ repository-url : https://test.pypi.org/legacy/
75
+ skip-existing : true
44
76
publish-to-pypi :
45
77
name : >-
46
78
Publish Python 🐍 distribution 📦 to PyPI
47
79
if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
48
80
needs :
49
- - build
81
+ - test
50
82
runs-on : ubuntu-latest
51
83
environment :
52
84
name : pypi
53
85
url : https://pypi.org/p/navground-learning
54
86
permissions :
55
87
id-token : write # IMPORTANT: mandatory for trusted publishing
56
88
steps :
57
- - name : Download all the dists
58
- uses : actions/download-artifact@v4
59
- with :
60
- name : python-package-distributions
61
- path : dist/
62
- - name : Publish distribution 📦 to PyPI
63
- uses : pypa/gh-action-pypi-publish@release/v1
64
- with :
65
- skip-existing : true
89
+ - name : Download all the dists
90
+ uses : actions/download-artifact@v4
91
+ with :
92
+ name : python-package-distributions
93
+ path : dist/
94
+ - name : Publish distribution 📦 to PyPI
95
+ uses : pypa/gh-action-pypi-publish@release/v1
96
+ with :
97
+ skip-existing : true
66
98
github-release :
67
99
name : >-
68
100
Sign the Python 🐍 distribution 📦 with Sigstore
69
101
and upload them to GitHub Release
70
102
needs :
71
- - publish-to-pypi
103
+ - publish-to-pypi
72
104
runs-on : ubuntu-latest
73
105
permissions :
74
106
contents : write # IMPORTANT: mandatory for making GitHub Releases
75
107
id-token : write # IMPORTANT: mandatory for sigstore
76
108
steps :
77
- - name : Download all the dists
78
- uses : actions/download-artifact@v4
79
- with :
80
- name : python-package-distributions
81
- path : dist/
82
- - name : Sign the dists with Sigstore
83
- uses : sigstore/gh-action-sigstore-python@v3.0.0
84
- with :
85
- inputs : >-
86
- ./dist/*.tar.gz
87
- ./dist/*.whl
88
- - name : Create GitHub Release
89
- env :
90
- GITHUB_TOKEN : ${{ github.token }}
91
- run : >-
92
- gh release create
93
- '${{ github.ref_name }}'
94
- --repo '${{ github.repository }}'
95
- --notes ""
96
- - name : Upload artifact signatures to GitHub Release
97
- env :
98
- GITHUB_TOKEN : ${{ github.token }}
99
- # Upload to GitHub Release using the `gh` CLI.
100
- # `dist/` contains the built packages, and the
101
- # sigstore-produced signatures and certificates.
102
- run : >-
103
- gh release upload
104
- '${{ github.ref_name }}' dist/**
105
- --repo '${{ github.repository }}'
109
+ - name : Download all the dists
110
+ uses : actions/download-artifact@v4
111
+ with :
112
+ name : python-package-distributions
113
+ path : dist/
114
+ - name : Sign the dists with Sigstore
115
+ uses : sigstore/gh-action-sigstore-python@v3.0.0
116
+ with :
117
+ inputs : >-
118
+ ./dist/*.tar.gz
119
+ ./dist/*.whl
120
+ - name : Create GitHub Release
121
+ env :
122
+ GITHUB_TOKEN : ${{ github.token }}
123
+ run : >-
124
+ gh release create
125
+ '${{ github.ref_name }}'
126
+ --repo '${{ github.repository }}'
127
+ --notes ""
128
+ - name : Upload artifact signatures to GitHub Release
129
+ env :
130
+ GITHUB_TOKEN : ${{ github.token }}
131
+ # Upload to GitHub Release using the `gh` CLI.
132
+ # `dist/` contains the built packages, and the
133
+ # sigstore-produced signatures and certificates.
134
+ run : >-
135
+ gh release upload
136
+ '${{ github.ref_name }}' dist/**
137
+ --repo '${{ github.repository }}'
0 commit comments