Skip to content

Commit

Permalink
update publish
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoxc committed Jun 20, 2024
1 parent 959e3cb commit b863f40
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ on:
- 'v*'
workflow_dispatch:
inputs:
ref:
description: 'Branch or Reference'
required: false
default: 'github'
task:
description: 'PyPI or TestPyPI'
required: true
default: 'None'
type: choice
options:
- none
- testpypi
- pypi
- all

jobs:
publish:
Expand All @@ -20,8 +26,24 @@ jobs:
- name: Check tag
id: check-tag
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]] || ${{ github.event_name == 'workflow_dispatch' }} ; then
echo ::set-output name=match::true
task="${{ github.event.inputs.task }}"
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
task="pypi"
fi
if [[ "$task" == "pypi" || "$task" == "all" ]]; then
echo "run_pypi=true" >> $GITHUB_OUTPUT
else
echo "run_pypi=false" >> $GITHUB_OUTPUT
fi
if [[ "$task" == "testpypi" || "$task" == "all" ]]; then
echo "run_testpypi=true" >> $GITHUB_OUTPUT
else
echo "run_testpypi=false" >> $GITHUB_OUTPUT
fi
if [[ "$task" == "none" ]]; then
echo "match=false" >> $GITHUB_OUTPUT
else
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Checkout repo
Expand All @@ -38,7 +60,7 @@ jobs:
workflow: wheels.yml
workflow_conclusion: success
branch: github
name: qepy-wheels
name: cp.*
path: dist/

- name: Set up Python
Expand All @@ -54,14 +76,14 @@ jobs:
python -m build --sdist
- name: Publish distribution to Test PyPI
if: steps.check-tag.outputs.match == 'true'
if: steps.check-tag.outputs.run_testpypi == 'true'
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution to PyPI
if: steps.check-tag.outputs.match == 'true'
if: steps.check-tag.outputs.run_pypi == 'true'
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit b863f40

Please sign in to comment.