Skip to content

Commit

Permalink
Add an upload destination input to wheels workflow manual dispatch (#112
Browse files Browse the repository at this point in the history
)

Add an upload destination input to wheels workflow manual dispatch
  • Loading branch information
alugowski authored Oct 15, 2023
1 parent f8cd3b4 commit 093c2ad
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ on:

# Enable Run Workflow button in GitHub UI
workflow_dispatch:
inputs:
# Manual dispatch allows optional upload of wheels to PyPI
upload_dest:
type: choice
description: Upload wheels to
options:
- No Upload
- PyPI
- Test PyPI

push:
branches: [ main ]
Expand Down Expand Up @@ -202,7 +211,7 @@ jobs:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# only upload releases to PyPI
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' && github.event_name == 'release' && github.event.action == 'published'
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'))

steps:
- uses: actions/setup-python@v4
Expand All @@ -214,14 +223,20 @@ jobs:
name: artifact
path: dist

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

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

0 comments on commit 093c2ad

Please sign in to comment.