66 workflow_dispatch :
77 inputs :
88 environment :
9- default : ' testpypi'
9+ description : The environment to publish to ("pypi", "testpypi", or "none").
10+ default : ' pypi'
11+ required : true
1012
1113env :
1214 dist-artifact-name : nitypes-distribution-packages
15+ environment-info : |
16+ {
17+ "pypi": {
18+ "base-url": "https://pypi.org",
19+ "upload-url": "https://upload.pypi.org/legacy/"
20+ },
21+ "testpypi": {
22+ "base-url": "https://test.pypi.org",
23+ "upload-url": "https://test.pypi.org/legacy/"
24+ }
25+ }
1326
1427jobs :
1528 check_nitypes :
@@ -29,42 +42,24 @@ jobs:
2942 uses : ni/python-actions/setup-python@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0
3043 - name : Set up Poetry
3144 uses : ni/python-actions/setup-poetry@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0
45+ - name : Check project version
46+ if : github.event_name == 'release'
47+ uses : ni/python-actions/check-project-version@c09765bfa2f886e2227f6c2525cb006348736349 # users/bkeryan/update-project-version
3248 - name : Build distribution packages
3349 run : poetry build
3450 - name : Upload build artifacts
3551 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3652 with :
3753 name : ${{ env.dist-artifact-name }}
3854 path : dist/*
39- publish_to_testpypi :
40- name : Publish nitypes to TestPyPI
41- if : github.event_name == 'workflow_dispatch' && inputs.environment == 'testpypi'
42- runs-on : ubuntu-latest
43- needs : [build_nitypes]
44- environment :
45- name : testpypi
46- url : https://test.pypi.org/p/nitypes
47- permissions :
48- id-token : write
49- steps :
50- - name : Download build artifacts
51- uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
52- with :
53- name : ${{ env.dist-artifact-name }}
54- path : dist/
55- - run : ls -lR
56- - name : Upload to PyPI
57- uses : pypa/gh-action-pypi-publish@release/v1
58- with :
59- repository-url : https://test.pypi.org/legacy/
6055 publish_to_pypi :
6156 name : Publish nitypes to PyPI
62- if : github.event_name == 'release' || inputs.environment == 'pypi '
57+ if : inputs.environment != 'none '
6358 runs-on : ubuntu-latest
6459 needs : [build_nitypes]
6560 environment :
66- name : pypi
67- url : https://pypi.org /p/nitypes
61+ name : ${{ inputs.environment }}
62+ url : ${{ fromJson(env.environment-info)[inputs.environment].base-url }} /p/nitypes
6863 permissions :
6964 id-token : write
7065 steps :
7469 name : ${{ env.dist-artifact-name }}
7570 path : dist/
7671 - run : ls -lR
77- - name : Upload to PyPI
72+ - name : Upload to ${{ inputs.environment }}
7873 uses : pypa/gh-action-pypi-publish@release/v1
74+ with :
75+ repository-url : ${{ fromJson(env.environment-info)[inputs.environment].upload-url }}
7976 update_version :
8077 name : Update nitypes version
8178 runs-on : ubuntu-latest
9188 - name : Set up Poetry
9289 uses : ni/python-actions/setup-poetry@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0
9390 - name : Update project version
94- uses : ni/python-actions/update-project-version@e183aaeec4ffab2bc331bf47093bccc086bc19d3 # users/bkeryan/update-project-version
91+ uses : ni/python-actions/update-project-version@c09765bfa2f886e2227f6c2525cb006348736349 # users/bkeryan/update-project-version
0 commit comments