Skip to content

Commit 1e97a01

Browse files
authored
Update component-release.yml
1 parent a083ffb commit 1e97a01

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

.github/workflows/component-release.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
release:
1111
if: github.event.pull_request.merged == true
12-
runs-on: ubuntu-latest
12+
runs-on: comcast-ubuntu-latest
1313

1414
steps:
1515
- name: Checkout repository
@@ -47,28 +47,37 @@ jobs:
4747
echo "git config completed"
4848
# Extract version from PR description
4949
PR_DESC="${{ github.event.pull_request.body }}"
50-
51-
VERSION_FROM_PR=$(echo "$PR_DESC" | grep -oiP 'version\s*:\s*\K[0-9]+\.[0-9]+\.[0-9]+(?=)' || true)
52-
53-
echo "Extracted version from PR: $VERSION_FROM_PR"
54-
5550
# Get top tag from CHANGELOG.md
5651
TOP_TAG=$(grep -m 1 -oP '^#### \[\K[^\]]+' CHANGELOG.md)
57-
if [[ -z "$VERSION_FROM_PR" ]]; then
58-
echo "Version not found in PR description"
59-
exit 1
60-
fi
6152
if [[ -z "$TOP_TAG" ]]; then
6253
echo "No version found in CHANGELOG.md!"
6354
exit 1
6455
fi
65-
# Compare PR version and top tag
66-
if [[ "$VERSION_FROM_PR" == "$TOP_TAG" || $(printf '%s\n%s' "$VERSION_FROM_PR" "$TOP_TAG" | sort -V | head -n1) != "$TOP_TAG" ]]; then
67-
echo "Invalid version provided"
56+
# Validate TOP_TAG format (semantic versioning: major.minor.patch)
57+
if [[ ! "$TOP_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
58+
echo "Invalid version format in CHANGELOG.md: $TOP_TAG. Expected format: major.minor.patch"
6859
exit 1
6960
fi
70-
RELEASE_VERSION="$VERSION_FROM_PR"
71-
echo "Using version from PR description: $RELEASE_VERSION"
61+
IFS='.' read -r major minor patch <<< "$TOP_TAG"
62+
VERSION_TYPE=$(echo "$PR_DESC" | grep -oiP 'version\s*:\s*\K(major|minor|patch)' | tr '[:upper:]' '[:lower:]')
63+
if [[ -z "$VERSION_TYPE" ]]; then
64+
echo "No version type found in PR description, defaulting to PATCH increment."
65+
patch=$((patch + 1))
66+
elif [[ "$VERSION_TYPE" == "major" ]]; then
67+
major=$((major + 1))
68+
minor=0
69+
patch=0
70+
elif [[ "$VERSION_TYPE" == "minor" ]]; then
71+
minor=$((minor + 1))
72+
patch=0
73+
elif [[ "$VERSION_TYPE" == "patch" ]]; then
74+
patch=$((patch + 1))
75+
else
76+
echo "Invalid version type in PR description: $VERSION_TYPE"
77+
exit 1
78+
fi
79+
RELEASE_VERSION="$major.$minor.$patch"
80+
echo "Using calculated version: $RELEASE_VERSION"
7281
echo "RELEASE_VERSION=$RELEASE_VERSION"
7382
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
7483
# Check if tag already exists
@@ -81,6 +90,7 @@ jobs:
8190
git add CHANGELOG.md
8291
git commit -m "$RELEASE_VERSION release changelog updates"
8392
git flow release publish
93+
8494
- name: Finish release and push (default git-flow messages)
8595
run: |
8696
set -e
@@ -89,6 +99,7 @@ jobs:
8999
git push origin main
90100
git push origin --tags
91101
git push origin develop
102+
92103
- name: Cleanup tag if workflow fails
93104
if: failure()
94105
run: |

0 commit comments

Comments
 (0)