Skip to content

Commit 093c2ad

Browse files
authored
Add an upload destination input to wheels workflow manual dispatch (#112)
Add an upload destination input to wheels workflow manual dispatch
1 parent f8cd3b4 commit 093c2ad

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ on:
66

77
# Enable Run Workflow button in GitHub UI
88
workflow_dispatch:
9+
inputs:
10+
# Manual dispatch allows optional upload of wheels to PyPI
11+
upload_dest:
12+
type: choice
13+
description: Upload wheels to
14+
options:
15+
- No Upload
16+
- PyPI
17+
- Test PyPI
918

1019
push:
1120
branches: [ main ]
@@ -202,7 +211,7 @@ jobs:
202211
needs: [build_wheels, build_sdist]
203212
runs-on: ubuntu-latest
204213
# only upload releases to PyPI
205-
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' && github.event_name == 'release' && github.event.action == 'published'
214+
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' && ((github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest != 'No Upload'))
206215

207216
steps:
208217
- uses: actions/setup-python@v4
@@ -214,14 +223,20 @@ jobs:
214223
name: artifact
215224
path: dist
216225

226+
# Upload to PyPI
217227
- uses: pypa/gh-action-pypi-publish@release/v1
228+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'PyPI')
218229
with:
219230
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists.
220231
skip-existing: true
221232
verbose: true
222-
# Real PyPI:
223233
password: ${{ secrets.PYPI_TOKEN }}
224234

225-
# Test PyPI:
226-
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
227-
# repository-url: https://test.pypi.org/legacy/
235+
# Upload to Test PyPI
236+
- uses: pypa/gh-action-pypi-publish@release/v1
237+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'Test PyPI'
238+
with:
239+
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists.
240+
skip-existing: true
241+
verbose: true
242+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)