12
12
description : " Upload generate package files to PyPI"
13
13
required : true
14
14
type : boolean
15
- use_prod_pypi :
16
- description : " Use production PyPI not Test PyPI"
17
- required : false
18
- type : boolean
15
+ pypi_environment :
16
+ description : " Which PyPI instance to publish to"
17
+ required : true
18
+ type : choice
19
+ options :
20
+ - testpypi
21
+ - pypi
19
22
20
23
jobs :
21
24
build_sdist :
@@ -72,17 +75,17 @@ jobs:
72
75
path : ./wheelhouse/*.whl
73
76
if-no-files-found : error
74
77
75
- upload_to_prod_pypi :
76
- name : Upload packages to PyPI
78
+ upload_to_pypi :
79
+ name : " Upload packages to PyPI"
77
80
needs : [build_sdist, build_wheels]
78
81
runs-on : ubuntu-24.04
79
- if : " ${{ inputs.upload_to_pypi && inputs.use_prod_pypi && startsWith(github.ref, 'refs/tags') }}"
82
+ if : " ${{ inputs.upload_to_pypi }}"
80
83
permissions :
81
84
contents : read
82
85
id-token : write # Needed for PyPI Trusted Publishing
83
86
environment :
84
- name : pypi
85
- url : https://pypi.org/p/jsonnet
87
+ name : " ${{ inputs.pypi_environment }} "
88
+ url : " ${{ inputs.pypi_environment == 'pypi' && ' https://pypi.org/p/jsonnet' || 'https://test.pypi.org/p/jsonnet' }} "
86
89
steps :
87
90
- uses : actions/download-artifact@v4
88
91
with :
@@ -98,38 +101,8 @@ jobs:
98
101
find cibw-wheels/ -type f -name '*.whl' -exec mv '{}' ./dist/ ';'
99
102
find sdist/ -type f -name '*.gz' -exec mv '{}' ./dist/ ';'
100
103
- name : Publish to PyPI
101
- uses : pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
102
- with :
103
- print-hash : true
104
-
105
- upload_to_test_pypi :
106
- name : Upload packages to TEST PyPI
107
- needs : [build_sdist, build_wheels]
108
- runs-on : ubuntu-24.04
109
- if : " ${{ inputs.upload_to_pypi && !inputs.use_prod_pypi }}"
110
- permissions :
111
- contents : read
112
- id-token : write # Needed for PyPI Trusted Publishing
113
- environment :
114
- name : testpypi
115
- url : https://test.pypi.org/p/jsonnet
116
- steps :
117
- - uses : actions/download-artifact@v4
118
- with :
119
- path : cibw-wheels
120
- pattern : cibw-wheels-*
121
- - uses : actions/download-artifact@v4
122
- with :
123
- path : sdist
124
- name : sdist
125
- - name : Flatten wheels to one directory
126
- run : |
127
- mkdir dist
128
- find cibw-wheels/ -type f -name '*.whl' -exec mv '{}' ./dist/ ';'
129
- find sdist/ -type f -name '*.gz' -exec mv '{}' ./dist/ ';'
130
- - name : Publish to TEST PyPI
131
104
uses : pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
132
105
with :
133
106
verbose : true
134
107
print-hash : true
135
- repository-url : https://test.pypi.org/legacy/
108
+ repository-url : " ${{ inputs.pypi_environment == 'testpypi' && ' https://test.pypi.org/legacy/' || '' }} "
0 commit comments