Skip to content

Commit dc11e39

Browse files
committed
use semver and get rid of alpha
1 parent 2b77bb1 commit dc11e39

File tree

1 file changed

+24
-54
lines changed

1 file changed

+24
-54
lines changed

.github/workflows/create-release-pr.yml

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ on:
66
release-type:
77
description: "Release type"
88
required: true
9-
default: "stable"
9+
default: "Current"
1010
type: choice
1111
options:
1212
- Current
1313
- Beta
14-
- Alpha
1514

1615
jobs:
1716
bump-version:
@@ -79,66 +78,43 @@ jobs:
7978
RELEASE_TYPE="${{ inputs.release-type }}"
8079
IS_FEATURE='${{ steps.get_prs.outputs.isFeature }}'
8180
82-
# Extract base version and determine current pre-release type
83-
if [[ "$CURRENT" =~ -alpha\. ]]; then
84-
BASE_VERSION="${CURRENT%-alpha.*}"
85-
PRERELEASE_NUM="${CURRENT##*-alpha.}"
86-
PRERELEASE_TYPE="alpha"
87-
elif [[ "$CURRENT" =~ -beta\. ]]; then
88-
BASE_VERSION="${CURRENT%-beta.*}"
89-
PRERELEASE_NUM="${CURRENT##*-beta.}"
81+
# Determine if current version is a prerelease
82+
if [[ "$CURRENT" =~ -beta\. ]]; then
9083
PRERELEASE_TYPE="beta"
9184
else
92-
BASE_VERSION="$CURRENT"
9385
PRERELEASE_TYPE="stable"
9486
fi
9587
96-
# Helper function to bump version
97-
bump_version() {
98-
local base=$1
99-
local is_feature=$2
100-
local major=${base:0:2}
101-
local minor=${base:2:2}
102-
local patch=${base:4:2}
103-
104-
if [[ "$is_feature" == "true" ]]; then
105-
minor=$(printf "%02d" $((10#$minor + 1)))
106-
patch="00"
107-
else
108-
patch=$(printf "%02d" $((10#$patch + 1)))
109-
fi
110-
111-
echo "${major}${minor}${patch}"
112-
}
113-
114-
# Determine new version based on current and desired release types
115-
if [[ "$RELEASE_TYPE" == "Alpha" ]]; then
116-
if [[ "$PRERELEASE_TYPE" == "alpha" ]]; then
117-
# Increment alpha number
118-
NEW_VERSION="$BASE_VERSION-alpha.$((PRERELEASE_NUM + 1))"
119-
else
120-
# New alpha release from stable or beta
121-
NEW_VERSION="$(bump_version "$BASE_VERSION" "$IS_FEATURE")-alpha.1"
122-
fi
123-
elif [[ "$RELEASE_TYPE" == "Beta" ]]; then
88+
# Calculate new version using semver
89+
if [[ "$RELEASE_TYPE" == "Beta" ]]; then
12490
if [[ "$PRERELEASE_TYPE" == "beta" ]]; then
125-
# Increment beta number
126-
NEW_VERSION="$BASE_VERSION-beta.$((PRERELEASE_NUM + 1))"
91+
# Increment existing beta
92+
NEW_VERSION=$(bunx semver -i prerelease --preid beta "$CURRENT")
12793
elif [[ "$PRERELEASE_TYPE" == "alpha" ]]; then
12894
# Promote alpha to beta
129-
NEW_VERSION="$BASE_VERSION-beta.1"
95+
BASE=$(echo "$CURRENT" | sed 's/-alpha\..*//')
96+
NEW_VERSION="$BASE-beta.1"
13097
else
131-
# New beta release from stable
132-
NEW_VERSION="$(bump_version "$BASE_VERSION" "$IS_FEATURE")-beta.1"
98+
# New beta from stable
99+
if [[ "$IS_FEATURE" == "true" ]]; then
100+
BASE=$(bunx semver -i minor "$CURRENT")
101+
else
102+
BASE=$(bunx semver -i patch "$CURRENT")
103+
fi
104+
NEW_VERSION="$BASE-beta.1"
133105
fi
134106
else
135107
# Release type is Current (stable)
136108
if [[ "$PRERELEASE_TYPE" != "stable" ]]; then
137-
# Promote pre-release to stable
138-
NEW_VERSION="$BASE_VERSION"
109+
# Promote prerelease to stable
110+
NEW_VERSION=$(echo "$CURRENT" | sed 's/-[a-z].*//')
139111
else
140112
# Bump stable version
141-
NEW_VERSION="$(bump_version "$CURRENT" "$IS_FEATURE")"
113+
if [[ "$IS_FEATURE" == "true" ]]; then
114+
NEW_VERSION=$(bunx semver -i minor "$CURRENT")
115+
else
116+
NEW_VERSION=$(bunx semver -i patch "$CURRENT")
117+
fi
142118
fi
143119
fi
144120
@@ -149,12 +125,6 @@ jobs:
149125
git checkout -b rel/${{ steps.new_version.outputs.version }}
150126
git push -u origin rel/${{ steps.new_version.outputs.version }}
151127
152-
- name: Create temp branch
153-
if: inputs.release-type == 'Alpha' || inputs.release-type == 'Beta'
154-
run: |
155-
git checkout -b release-${{ steps.new_version.outputs.version }}
156-
git push -u origin release-${{ steps.new_version.outputs.version }}
157-
158128
# Cordova specific steps
159129
- name: Update sdk version
160130
run: |
@@ -165,7 +135,7 @@ jobs:
165135
# Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215)
166136
# For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15)
167137
BASE_VERSION=$(echo "$NEW_VERSION" | sed 's/-[a-z].*//')
168-
WRAPPER_VERSION=$(echo "$BASE_VERSION" | sed 's/\.//g' | awk '{printf "%06d", $0}')
138+
WRAPPER_VERSION=$(echo "$BASE_VERSION" | awk -F'.' '{printf "%02d%02d%02d", $1, $2, $3}')
169139
170140
# Update package.json version
171141
npm pkg set version="$NEW_VERSION"

0 commit comments

Comments
 (0)