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
1615jobs :
1716 bump-version :
@@ -74,87 +73,40 @@ jobs:
7473
7574 - name : Calculate new version
7675 id : new_version
76+ shell : bash
7777 run : |
78- CURRENT="${{ steps.current_version.outputs.current }}"
79- RELEASE_TYPE="${{ inputs.release-type }}"
80- IS_FEATURE='${{ steps.get_prs.outputs.isFeature }}'
81-
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.}"
90- PRERELEASE_TYPE="beta"
91- else
92- BASE_VERSION="$CURRENT"
93- PRERELEASE_TYPE="stable"
94- fi
95-
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))"
78+ set -euo pipefail
79+ CUR="${{ steps.current_version.outputs.current }}"
80+ TYPE="${{ inputs.release-type }}"
81+ IS_FEAT='${{ steps.get_prs.outputs.isFeature }}'
82+
83+ PRE=$([[ "$CUR" =~ -beta\. ]] && echo beta || echo stable)
84+ INC=$([ "$IS_FEAT" = "true" ] && echo minor || echo patch)
85+ BASE_NO_PRE="$(echo "$CUR" | sed 's/-.*//')"
86+
87+ if [ "$TYPE" = "Beta" ]; then
88+ if [ "$PRE" = "beta" ]; then
89+ NEW="$(bunx semver -i prerelease --preid beta "$CUR")"
11990 else
120- # New alpha release from stable or beta
121- NEW_VERSION="$(bump_version "$BASE_VERSION" "$IS_FEATURE")-alpha.1"
91+ NEW="$(bunx semver -i "$INC" "$BASE_NO_PRE")-beta.1"
12292 fi
123- elif [[ "$RELEASE_TYPE" == "Beta" ]]; then
124- if [[ "$PRERELEASE_TYPE" == "beta" ]]; then
125- # Increment beta number
126- NEW_VERSION="$BASE_VERSION-beta.$((PRERELEASE_NUM + 1))"
127- elif [[ "$PRERELEASE_TYPE" == "alpha" ]]; then
128- # Promote alpha to beta
129- NEW_VERSION="$BASE_VERSION-beta.1"
93+ elif [ "$TYPE" = "Current" ]; then
94+ if [ "$PRE" = "beta" ]; then
95+ NEW="$BASE_NO_PRE" # promote beta -> stable
13096 else
131- # New beta release from stable
132- NEW_VERSION="$(bump_version "$BASE_VERSION" "$IS_FEATURE")-beta.1"
97+ NEW="$(bunx semver -i "$INC" "$CUR")"
13398 fi
13499 else
135- # Release type is Current (stable)
136- if [[ "$PRERELEASE_TYPE" != "stable" ]]; then
137- # Promote pre-release to stable
138- NEW_VERSION="$BASE_VERSION"
139- else
140- # Bump stable version
141- NEW_VERSION="$(bump_version "$CURRENT" "$IS_FEATURE")"
142- fi
100+ echo "release-type must be Beta or Current" >&2; exit 1
143101 fi
144102
145- echo "version=$NEW_VERSION " >> $GITHUB_OUTPUT
103+ echo "version=$NEW " >> " $GITHUB_OUTPUT"
146104
147105 - name : Create release branch
148106 run : |
149107 git checkout -b rel/${{ steps.new_version.outputs.version }}
150108 git push -u origin rel/${{ steps.new_version.outputs.version }}
151109
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-
158110 # Cordova specific steps
159111 - name : Update sdk version
160112 run : |
@@ -165,7 +117,7 @@ jobs:
165117 # Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215)
166118 # For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15)
167119 BASE_VERSION=$(echo "$NEW_VERSION" | sed 's/-[a-z].*//')
168- WRAPPER_VERSION=$(echo "$BASE_VERSION" | sed 's/\.//g' | awk '{printf "%06d ", $0 }')
120+ WRAPPER_VERSION=$(echo "$BASE_VERSION" | awk -F'.' '{printf "%02d%02d%02d ", $1, $2, $3 }')
169121
170122 # Update package.json version
171123 npm pkg set version="$NEW_VERSION"
0 commit comments