Skip to content

Commit 8df0f73

Browse files
committed
WMSDK-450: Manual branch preparation
1 parent 1fdff83 commit 8df0f73

1 file changed

Lines changed: 192 additions & 0 deletions

File tree

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: "Manual Release Prep: React Native"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: 'React Native release version (semver: X.Y.Z or X.Y.Z-rc)'
8+
required: true
9+
android_sdk_version:
10+
description: 'Native Android SDK version (optional, defaults to RN version)'
11+
required: false
12+
default: ''
13+
ios_sdk_version:
14+
description: 'Native iOS SDK version (optional, defaults to RN version)'
15+
required: false
16+
default: ''
17+
source_branch:
18+
description: 'Create branch from'
19+
required: true
20+
default: 'develop'
21+
target_branch:
22+
description: 'Pull Request to'
23+
required: true
24+
default: 'master'
25+
26+
jobs:
27+
validate-input:
28+
name: Validate versions format
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Check release_version
32+
run: |
33+
V=${{ github.event.inputs.release_version }}
34+
echo "Input release_version=$V"
35+
if ! [[ "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
36+
echo "❌ release_version must be X.Y.Z or X.Y.Z-rc"
37+
exit 1
38+
fi
39+
- name: Check android_sdk_version if set
40+
if: ${{ github.event.inputs.android_sdk_version != '' }}
41+
run: |
42+
A=${{ github.event.inputs.android_sdk_version }}
43+
echo "Input android_sdk_version=$A"
44+
if ! [[ "$A" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
45+
echo "❌ android_sdk_version must be X.Y.Z or X.Y.Z-rc"
46+
exit 1
47+
fi
48+
- name: Check ios_sdk_version if set
49+
if: ${{ github.event.inputs.ios_sdk_version != '' }}
50+
run: |
51+
I=${{ github.event.inputs.ios_sdk_version }}
52+
echo "Input ios_sdk_version=$I"
53+
if ! [[ "$I" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
54+
echo "❌ ios_sdk_version must be X.Y.Z or X.Y.Z-rc"
55+
exit 1
56+
fi
57+
58+
validate-branches:
59+
name: Validate source & target branches exist
60+
runs-on: ubuntu-latest
61+
needs: validate-input
62+
steps:
63+
- uses: actions/checkout@v4
64+
with: { fetch-depth: 0 }
65+
- name: Check source branch
66+
run: |
67+
SRC=${{ github.event.inputs.source_branch }}
68+
if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then
69+
echo "❌ source_branch '$SRC' does not exist on origin"
70+
exit 1
71+
fi
72+
- name: Check target branch
73+
run: |
74+
DST=${{ github.event.inputs.target_branch }}
75+
if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then
76+
echo "❌ target_branch '$DST' does not exist on origin"
77+
exit 1
78+
fi
79+
80+
bump_and_branch:
81+
name: Create release branch & bump versions
82+
runs-on: ubuntu-latest
83+
needs: validate-branches
84+
outputs:
85+
release_branch: ${{ steps.bump.outputs.release_branch }}
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
ref: ${{ github.event.inputs.source_branch }}
90+
fetch-depth: 0
91+
92+
- name: Configure Git
93+
run: |
94+
git config user.name "github-actions[bot]"
95+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96+
97+
- id: bump
98+
name: Create branch & apply bumps
99+
run: |
100+
set -euo pipefail
101+
VERSION="${{ github.event.inputs.release_version }}"
102+
AND_VER="${{ github.event.inputs.android_sdk_version }}"
103+
IO_VER="${{ github.event.inputs.ios_sdk_version }}"
104+
SRC="${{ github.event.inputs.source_branch }}"
105+
REL="release/$VERSION"
106+
107+
# fallback to RN version
108+
[ -z "$AND_VER" ] && AND_VER="$VERSION"
109+
[ -z "$IO_VER" ] && IO_VER="$VERSION"
110+
111+
echo "→ Branching from $SRC into $REL"
112+
git checkout -b "$REL"
113+
114+
##############################################################################
115+
# 1) package.json: bump "target-version"
116+
##############################################################################
117+
echo "→ Bumping package.json target-version"
118+
sed -i "s/\"target-version\": \".*\"/\"target-version\": \"$VERSION\"/" package.json
119+
git add package.json
120+
121+
##############################################################################
122+
# 2) Android build.gradle: bump cloud.mindbox:mobile-sdk:<version>
123+
##############################################################################
124+
echo "→ Bumping Android SDK in android/build.gradle"
125+
sed -i "s|\(api 'cloud.mindbox:mobile-sdk:\).*|\1$AND_VER'|" android/build.gradle
126+
git add android/build.gradle
127+
128+
##############################################################################
129+
# 3) iOS podspec: bump Mindbox and MindboxNotifications dependencies
130+
##############################################################################
131+
echo "→ Bumping iOS SDK in MindboxSdk.podspec"
132+
sed -i -E "s/(s\.dependency \"Mindbox\", \").*(\")/\1$IO_VER\2/" MindboxSdk.podspec
133+
sed -i -E "s/(s\.dependency \"MindboxNotifications\", \").*(\")/\1$IO_VER\2/" MindboxSdk.podspec
134+
git add MindboxSdk.podspec
135+
136+
##############################################################################
137+
# 4) CHANGELOG.md: insert Unreleased section at top
138+
##############################################################################
139+
echo "→ Inserting Unreleased section into CHANGELOG.md"
140+
awk -v a="$AND_VER" -v i="$IO_VER" '
141+
/^# Changelog/ {
142+
print
143+
print ""
144+
print "## [Unreleased]"
145+
print ""
146+
print "### Changes"
147+
print "- Upgrade Android SDK dependency to v" a
148+
print "- Upgrade iOS SDK dependency to v" i
149+
print ""
150+
next
151+
}
152+
{ print }
153+
' CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md
154+
git add CHANGELOG.md
155+
156+
##############################################################################
157+
# 5) Final commit
158+
##############################################################################
159+
git commit -m "Bump RN SDK versions: core=$VERSION, android=$AND_VER, ios=$IO_VER"
160+
echo "release_branch=$REL" >> $GITHUB_OUTPUT
161+
162+
- name: Push release branch
163+
run: git push --set-upstream origin ${{ steps.bump.outputs.release_branch }}
164+
165+
create_pull_request:
166+
name: Create Pull Request
167+
runs-on: ubuntu-latest
168+
needs: bump_and_branch
169+
steps:
170+
- name: Build PR body and open PR
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }}
173+
SRC: ${{ needs.bump_and_branch.outputs.release_branch }}
174+
DST: ${{ github.event.inputs.target_branch }}
175+
REPO: ${{ github.repository }}
176+
run: |
177+
AND_VER=${{ github.event.inputs.android_sdk_version }}
178+
IO_VER=${{ github.event.inputs.ios_sdk_version }}
179+
[ -z "$AND_VER" ] && AND_VER="${{ github.event.inputs.release_version }}"
180+
[ -z "$IO_VER" ] && IO_VER="${{ github.event.inputs.release_version }}"
181+
182+
BODY=$(
183+
printf 'Automated PR: merge `%s` into `%s`\n\n**Versions:**\n- React Native SDK: `%s`\n- Android SDK: `%s`\n- iOS SDK: `%s`' \
184+
"$SRC" "$DST" "${{ github.event.inputs.release_version }}" "$AND_VER" "$IO_VER"
185+
)
186+
187+
gh pr create \
188+
--repo "$REPO" \
189+
--base "$DST" \
190+
--head "$SRC" \
191+
--title "Release ${{ github.event.inputs.release_version }}" \
192+
--body "$BODY"

0 commit comments

Comments
 (0)