Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

ci: ignore non-version release tags

XZH8c7028327845
diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml
index a6ad73fb7..4a993617e 100644
--- a/.github/workflows/docker-release.yml
+++ b/.github/workflows/docker-release.yml
@@ -19,8 +19,30 @@ permissions:
packages: write
jobs:
+ validate-release-tag:
+ name: Validate release tag
+ if: startsWith(github.event.release.tag_name, 'v')
+ runs-on: ubuntu-latest
+ steps:
+ - name: Require an image version tag
+ shell: python
+ run: |
+ import os
+ import re
+
+ tag = os.environ["RELEASE_TAG"]
+ pattern = r"^v\d+\.\d+\.\d+(?:[0-9A-Za-z._+-]*)?$"
+ if not re.fullmatch(pattern, tag):
+ raise SystemExit(
+ f"Release tag {tag!r} is not an image version tag "
+ "(expected vX.Y.Z with an optional suffix)."
+ )
+ env:
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
+
build-and-push:
name: Build and Push Multi-Platform Docker Image
+ needs: validate-release-tag
runs-on: ubuntu-latest
steps:
diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml
index 5394bcfa0..f3fdcde62 100644
--- a/.github/workflows/pypi-release.yml
+++ b/.github/workflows/pypi-release.yml
@@ -26,8 +26,30 @@ concurrency:
cancel-in-progress: false
jobs:
+ validate-release-tag:
+ name: Validate release tag
+ if: startsWith(github.event.release.tag_name, 'v')
+ runs-on: ubuntu-latest
+ steps:
+ - name: Require a package version tag
+ shell: python
+ run: |
+ import os
+ import re
+
+ tag = os.environ["RELEASE_TAG"]
+ pattern = r"^v\d+\.\d+\.\d+(?:[0-9A-Za-z._+-]*)?$"
+ if not re.fullmatch(pattern, tag):
+ raise SystemExit(
+ f"Release tag {tag!r} is not a package version tag "
+ "(expected vX.Y.Z with an optional suffix)."
+ )
+ env:
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
+
build-and-publish:
name: Build and Publish PyPI Package
+ needs: validate-release-tag
runs-on: ubuntu-latest
environment:
name: pypi