From e0527bc1d8f9cd08167a5bd5a8fbb76f9409c718 Mon Sep 17 00:00:00 2001 From: Janez Podhostnik Date: Tue, 11 Jul 2023 17:36:03 +0200 Subject: [PATCH] add workflow to validate git tags --- .github/workflows/semver-tags.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/semver-tags.yaml diff --git a/.github/workflows/semver-tags.yaml b/.github/workflows/semver-tags.yaml new file mode 100644 index 00000000000..41ebe625744 --- /dev/null +++ b/.github/workflows/semver-tags.yaml @@ -0,0 +1,22 @@ +name: Verify Tag + +on: + push: + tags: + - '*' + +jobs: + SemVer-Check: + runs-on: ubuntu-latest + steps: + - name: Check if tag is SemVer compliant + # the tag should be in semver format, but can optionally be prepended by "any_text_with_slashes/" and "v" + # valid examples crypto/v0.24.5-fvm, tools/flaky_test_monitor/v0.23.5, v0.23.5, 0.23.5-fvm + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + if [[ "${TAG_NAME}" =~ ^(.+\/)*v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then + echo "Tag $TAG_NAME is SemVer compliant" + else + echo "Tag $TAG_NAME is not SemVer compliant" + exit 1 + fi