3030 - name : Validate Release Tag Format
3131 id : validate_tag
3232 env :
33- # Use the repo variable for the regex if it exists, otherwise use the default.
3433 VERSION_REGEX : ${{ vars.VERSION_REGEX || '^v?[0-9]+\.[0-9]+\.[0-9]+$' }}
3534 run : |
3635 TAG_NAME="${{ steps.get_release_b.outputs.release }}"
4544 if [[ "$TAG_NAME" =~ $VERSION_REGEX ]]; then
4645 echo "Tag '$TAG_NAME' matches the required format."
4746 echo "is_valid=true" >> "$GITHUB_OUTPUT"
47+ # Extract matched portion (Bash stores full match in BASH_REMATCH[0])
48+ new_version="${BASH_REMATCH[0]}"
49+ echo "Extracted version: $new_version"
50+ echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
4851 else
4952 echo "Tag '$TAG_NAME' does not match the required format. Ignoring."
5053 echo "is_valid=false" >> "$GITHUB_OUTPUT"
7073 id : check_tag
7174 if : steps.validate_tag.outputs.is_valid == 'true'
7275 env :
73- RELEASE_TAG : ${{ steps.get_release_b .outputs.release }}
76+ RELEASE_TAG : v ${{ steps.validate_tag .outputs.new_version }}
7477 run : |
7578 if git tag --list | grep -q "^${RELEASE_TAG}$"; then
7679 echo "Tag '$RELEASE_TAG' already exists. No action needed."
@@ -81,10 +84,11 @@ jobs:
8184 fi
8285
8386 - name : Create and push new tag
87+ id : create_and_push
8488 # This step only runs if the tag is valid AND new.
8589 if : steps.check_tag.outputs.create_tag == 'true'
8690 env :
87- RELEASE_TAG : ${{ steps.get_release_b .outputs.release }}
91+ RELEASE_TAG : v ${{ steps.validate_tag .outputs.new_version }}
8892 run : |
8993 RELEASE_TAG="v${RELEASE_TAG#v}" # Ensure the tag starts with 'v'
9094
0 commit comments