From 98bf8f5b85d318cd6ad3c7105fdde3149a2ef8ed Mon Sep 17 00:00:00 2001 From: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Date: Sun, 28 Jan 2024 20:37:52 +0530 Subject: [PATCH] ci: fix `create-hot-fix-tag` workflow to filter for `CalVer` tags (#3463) --- .github/workflows/create-hotfix-branch.yml | 2 +- .github/workflows/create-hotfix-tag.yml | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-hotfix-branch.yml b/.github/workflows/create-hotfix-branch.yml index e96508165fc..d7afb388f2f 100644 --- a/.github/workflows/create-hotfix-branch.yml +++ b/.github/workflows/create-hotfix-branch.yml @@ -25,7 +25,7 @@ jobs: - name: Check if the input is valid tag shell: bash run: | - if [[ ${{github.ref}} =~ ^refs/tags/[0-9]{4}\.[0-9]{2}\.[0-9]{2}.[0-9]+$ ]]; then + if [[ ${{github.ref}} =~ ^refs/tags/[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.[0-9]+$ ]]; then echo "::notice::${{github.ref}} is a CalVer tag." else echo "::error::${{github.ref}} is not a CalVer tag." diff --git a/.github/workflows/create-hotfix-tag.yml b/.github/workflows/create-hotfix-tag.yml index 8989094f1d2..2250ce7ece5 100644 --- a/.github/workflows/create-hotfix-tag.yml +++ b/.github/workflows/create-hotfix-tag.yml @@ -31,7 +31,7 @@ jobs: - name: Check if the input is valid hotfix branch shell: bash run: | - if [[ ${{github.ref}} =~ ^refs/heads/hotfix-[0-9]{4}\.[0-9]{2}\.[0-9]{2}.[0-9]+$ ]]; then + if [[ ${{github.ref}} =~ ^refs/heads/hotfix-[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.[0-9]+$ ]]; then echo "::notice::${{github.ref}} is a valid hotfix branch." else echo "::error::${{github.ref}} is not a valid hotfix branch." @@ -56,7 +56,7 @@ jobs: local previous_hotfix_number local next_tag - previous_hotfix_number="$(echo "${previous_tag}" | awk -F. '{ print $4 }' | gsed -oE 's/([0-9]+)(-hotfix([0-9]+))?/\3/')" + previous_hotfix_number="$(echo "${previous_tag}" | awk -F. '{ print $4 }' | sed -E 's/([0-9]+)(-hotfix([0-9]+))?/\3/')" if [[ -z "${previous_hotfix_number}" ]]; then # Previous tag was not a hotfix tag @@ -70,7 +70,13 @@ jobs: echo "${next_tag}" } - PREVIOUS_TAG="$(git tag --merged | sort --version-sort | tail --lines 1)" + # Search for date-like tags (no strict checking), sort and obtain previous tag + PREVIOUS_TAG="$( + git tag --merged \ + | grep --extended-regexp '[0-9]{4}\.[0-9]{2}\.[0-9]{2}' \ + | sort --version-sort \ + | tail --lines 1 + )" NEXT_TAG="$(get_next_tag "${PREVIOUS_TAG}")" echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV