Skip to content

Commit d0dfb3e

Browse files
Add tag and branch validation
1 parent fca9f34 commit d0dfb3e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

.github/workflows/release.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,20 @@ jobs:
2525
with:
2626
fetch-depth: 0
2727

28-
- name: Validate tag format
28+
- name: Validate tag
2929
run: |
3030
if ! echo "$VERSION_NUM" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
3131
echo "Tag $VERSION_NUM does not follow semantic version pattern (x.y.z). Skipping release."
3232
exit 78 # neutral exit code
3333
fi
3434
echo "Tag $VERSION_NUM follows valid semantic version pattern"
3535
36-
- name: Check if tag is from release branch
37-
run: |
38-
# Get the branch that contains this tag
39-
BRANCHES=$(git branch -r --contains $COMMIT_SHA | grep -E 'origin/[0-9]+\.[0-9]+' || true)
40-
if [ -z "$BRANCHES" ]; then
41-
echo "Tag $VERSION_NUM is not from a *.* release branch. Skipping release."
42-
exit 78 # neutral exit code
43-
fi
44-
echo "Tag is from a valid release branch: $BRANCHES"
36+
# Verify release tag is made on the correct major.minor version branch.
37+
# The command will fail with exit code 1 if the tag is not on a valid release branch.
38+
MAJOR_MINOR=$(echo "$VERSION_NUM" | cut -d'.' -f1,2)
39+
git branch --remote --contains $COMMIT_SHA origin/$MAJOR_MINOR
40+
41+
echo "Tag is from a valid branch."
4542
4643
- name: Download sagemaker artifacts by commit ID
4744
run: |

0 commit comments

Comments
 (0)