Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,45 @@ jobs:
run: |
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"

# Run dry-run
# Run semantic-release dry-run to determine bump type
npx semantic-release --dry-run --no-ci > semantic-output.txt 2>&1 || true
cat semantic-output.txt

# Parse output
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)

if [ -z "$NEXT_VERSION" ]; then
# Check if semantic-release determined a new version is needed
if ! grep -q "The next release version is" semantic-output.txt; then
echo "::notice::No new version needed."
echo "should_create_pr=false" >> $GITHUB_OUTPUT
exit 0
fi

# Get the version that semantic-release would create (for comparison)
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)

# Strip -beta suffix from current version to get base version
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-beta$//')

# Parse current version components
CURRENT_MAJOR=$(echo "$BASE_VERSION" | cut -d. -f1)
CURRENT_MINOR=$(echo "$BASE_VERSION" | cut -d. -f2)
CURRENT_PATCH=$(echo "$BASE_VERSION" | cut -d. -f3)

# Parse semantic-release suggested version components
SR_MAJOR=$(echo "$SR_VERSION" | cut -d. -f1)
SR_MINOR=$(echo "$SR_VERSION" | cut -d. -f2)
SR_PATCH=$(echo "$SR_VERSION" | cut -d. -f3)

# Determine bump type and apply to current version
if [ "$SR_MAJOR" -gt "$CURRENT_MAJOR" ]; then
# Major bump
NEXT_VERSION="$((CURRENT_MAJOR + 1)).0.0"
elif [ "$SR_MINOR" -gt "$CURRENT_MINOR" ]; then
# Minor bump
NEXT_VERSION="${CURRENT_MAJOR}.$((CURRENT_MINOR + 1)).0"
else
# Patch bump
NEXT_VERSION="${CURRENT_MAJOR}.${CURRENT_MINOR}.$((CURRENT_PATCH + 1))"
fi

# Create beta version
BETA_VERSION="${NEXT_VERSION}-beta"

Expand Down
9 changes: 8 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"branches": ["master"],
"branches": [
"master",
{
"name": "stable-beta",
"prerelease": "beta",
"publish": false
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
Expand Down