diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index d9a23092..893a452a 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -9,6 +9,13 @@ on: release: types: [published] workflow_dispatch: + inputs: + publish: + type: choice + description: 'Publish to TestPyPI?' + options: + - false + - true jobs: build-and-publish: @@ -59,8 +66,11 @@ jobs: run: python -m zipfile --list dist/pylhe-*.whl - name: Publish distribution 📦 to Test PyPI - # every PR will trigger a push event on main, so check the push event is actually coming from main - if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'scikit-hep/pylhe' + # Publish to TestPyPI on tag events of if manually triggered + # Compare to 'true' string as booleans get turned into strings in the console + if: >- + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'scikit-hep/pylhe') + || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' && github.repository == 'scikit-hep/pylhe') uses: pypa/gh-action-pypi-publish@v1.6.4 with: password: ${{ secrets.test_pypi_password }}