Skip to content

Commit

Permalink
CI: Add tag check for release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Jan 18, 2024
1 parent 5288f65 commit c96e9da
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,26 @@ jobs:
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python setup.py sdist bdist_wheel
- name: Check Tag
id: check-tag
# https://packaging.python.org/en/latest/specifications/version-specifiers/#pre-releases
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+a[0-9]+$ ]]; then
echo "match=prerelease" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+b[0-9]+$ ]]; then
echo "match=prerelease" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$ ]]; then
echo "match=release" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=release" >> $GITHUB_OUTPUT
else
echo "match=dirty" >> $GITHUB_OUTPUT
fi
- name: Publish distribution to Test PyPI
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && steps.check-tag.outputs.match == 'prerelease'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') && steps.check-tag.outputs.match == 'release'
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit c96e9da

Please sign in to comment.