From b863f40ff22f030512e00f0fe6855a0a24fdd55c Mon Sep 17 00:00:00 2001 From: shaoxc Date: Thu, 20 Jun 2024 06:41:04 -0400 Subject: [PATCH] update publish --- .github/workflows/publish.yml | 40 +++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7e0036b..fd406fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 @@ -38,7 +60,7 @@ jobs: workflow: wheels.yml workflow_conclusion: success branch: github - name: qepy-wheels + name: cp.* path: dist/ - name: Set up Python @@ -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/gh-action-pypi-publish@v1.7.1 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/gh-action-pypi-publish@v1.7.1 with: password: ${{ secrets.PYPI_API_TOKEN }}