Skip to content

Commit ec6070b

Browse files
authored
Merge pull request #106 from newrelic/beta-release-workflow
feat: beta release workflow update
2 parents ebb1f5b + 131dd23 commit ec6070b

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

.github/workflows/beta-release.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,45 @@ jobs:
5252
run: |
5353
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
5454
55-
# Run dry-run
55+
# Run semantic-release dry-run to determine bump type
5656
npx semantic-release --dry-run --no-ci > semantic-output.txt 2>&1 || true
5757
cat semantic-output.txt
5858
59-
# Parse output
60-
NEXT_VERSION=$(grep "The next release version is" semantic-output.txt | sed -E 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | head -1)
61-
62-
if [ -z "$NEXT_VERSION" ]; then
59+
# Check if semantic-release determined a new version is needed
60+
if ! grep -q "The next release version is" semantic-output.txt; then
6361
echo "::notice::No new version needed."
6462
echo "should_create_pr=false" >> $GITHUB_OUTPUT
6563
exit 0
6664
fi
6765
66+
# Get the version that semantic-release would create (for comparison)
67+
SR_VERSION=$(grep "The next release version is" semantic-output.txt | sed -E 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | head -1)
68+
69+
# Strip -beta suffix from current version to get base version
70+
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-beta$//')
71+
72+
# Parse current version components
73+
CURRENT_MAJOR=$(echo "$BASE_VERSION" | cut -d. -f1)
74+
CURRENT_MINOR=$(echo "$BASE_VERSION" | cut -d. -f2)
75+
CURRENT_PATCH=$(echo "$BASE_VERSION" | cut -d. -f3)
76+
77+
# Parse semantic-release suggested version components
78+
SR_MAJOR=$(echo "$SR_VERSION" | cut -d. -f1)
79+
SR_MINOR=$(echo "$SR_VERSION" | cut -d. -f2)
80+
SR_PATCH=$(echo "$SR_VERSION" | cut -d. -f3)
81+
82+
# Determine bump type and apply to current version
83+
if [ "$SR_MAJOR" -gt "$CURRENT_MAJOR" ]; then
84+
# Major bump
85+
NEXT_VERSION="$((CURRENT_MAJOR + 1)).0.0"
86+
elif [ "$SR_MINOR" -gt "$CURRENT_MINOR" ]; then
87+
# Minor bump
88+
NEXT_VERSION="${CURRENT_MAJOR}.$((CURRENT_MINOR + 1)).0"
89+
else
90+
# Patch bump
91+
NEXT_VERSION="${CURRENT_MAJOR}.${CURRENT_MINOR}.$((CURRENT_PATCH + 1))"
92+
fi
93+
6894
# Create beta version
6995
BETA_VERSION="${NEXT_VERSION}-beta"
7096

.releaserc.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
2-
"branches": ["master"],
2+
"branches": [
3+
"master",
4+
{
5+
"name": "stable-beta",
6+
"prerelease": "beta",
7+
"publish": false
8+
}
9+
],
310
"plugins": [
411
[
512
"@semantic-release/commit-analyzer",

0 commit comments

Comments
 (0)