1+ name : " Manual Release Prep: Branch & Version Bump"
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ release_version :
7+ description : ' Release version (e.g. 1.2.3 or 1.2.3-rc)'
8+ required : true
9+ source_branch :
10+ description : ' Create branch from'
11+ required : true
12+ default : ' develop'
13+ target_branch :
14+ description : ' Pull Request to'
15+ required : true
16+ default : ' master'
17+
18+ jobs :
19+ validate-input :
20+ name : Validate release_version format
21+ runs-on : ubuntu-latest
22+ steps :
23+ - name : Check version matches semver or semver-rc
24+ run : |
25+ VER="${{ github.event.inputs.release_version }}"
26+ echo "→ release_version = $VER"
27+ if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
28+ echo "❌ release_version must be X.Y.Z or X.Y.Z-rc"
29+ exit 1
30+ fi
31+
32+ validate-branches :
33+ name : Validate branch names
34+ runs-on : ubuntu-latest
35+ needs : validate-input
36+ steps :
37+ - name : Checkout minimal repo
38+ uses : actions/checkout@v4
39+ with :
40+ fetch-depth : 0
41+
42+ - name : Validate source branch exists
43+ run : |
44+ SRC="${{ github.event.inputs.source_branch }}"
45+ if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then
46+ echo "❌ source_branch '$SRC' does not exist on origin"
47+ exit 1
48+ fi
49+
50+ - name : Validate target branch exists
51+ run : |
52+ DST="${{ github.event.inputs.target_branch }}"
53+ if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then
54+ echo "❌ target_branch '$DST' does not exist on origin"
55+ exit 1
56+ fi
57+
58+ bump_and_branch :
59+ name : Create release branch & bump version
60+ runs-on : ubuntu-latest
61+ needs : validate-branches
62+ outputs :
63+ release_branch : ${{ steps.bump.outputs.release_branch }}
64+ steps :
65+ - name : Checkout source branch
66+ uses : actions/checkout@v4
67+ with :
68+ ref : ${{ github.event.inputs.source_branch }}
69+ fetch-depth : 0
70+
71+ - name : Configure Git identity for GitHub Action Bot
72+ run : |
73+ git config user.name "github-actions[bot]"
74+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
75+
76+ - name : Create release branch & bump version
77+ id : bump
78+ run : |
79+ VERSION="${{ github.event.inputs.release_version }}"
80+ SRC="${{ github.event.inputs.source_branch }}"
81+ REL="release/$VERSION"
82+
83+ echo "→ Branching from $SRC into $REL"
84+ git checkout -b "$REL"
85+
86+ echo "→ Running bump script on $REL"
87+ ./.github/bump_versions_in_release_branch.sh "$VERSION"
88+
89+ echo "release_branch=$REL" >> $GITHUB_OUTPUT
90+
91+ - name : Push release branch
92+ run : |
93+ git push origin "${{ steps.bump.outputs.release_branch }}"
94+
95+ check_sdk_version :
96+ name : Check SDK Version
97+ runs-on : ubuntu-latest
98+ needs : bump_and_branch
99+ steps :
100+ - name : Checkout the release branch
101+ uses : actions/checkout@v4
102+ with :
103+ ref : ${{ needs.bump_and_branch.outputs.release_branch }}
104+ fetch-depth : 0
105+
106+ - name : Pull latest changes
107+ run : git pull
108+
109+ - name : Validate sdkVersion
110+ run : |
111+ EXPECT="${{ github.event.inputs.release_version }}"
112+ SDK_VERSION=$(grep -E '^SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2)
113+ echo "→ Found in code: $SDK_VERSION, expected: $EXPECT"
114+ if [ "$SDK_VERSION" != "$EXPECT" ]; then
115+ echo "❌ SDK version does not match!"
116+ exit 1
117+ fi
118+
119+ create_pull_request :
120+ name : Create Pull Request
121+ runs-on : ubuntu-latest
122+ needs : [bump_and_branch, check_sdk_version]
123+ steps :
124+ - name : Create PR via GitHub CLI
125+ env :
126+ GH_TOKEN : ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }}
127+ SRC : ${{ needs.bump_and_branch.outputs.release_branch }}
128+ DST : ${{ github.event.inputs.target_branch }}
129+ REPO : ${{ github.repository }}
130+ run : |
131+ echo "→ Creating PR from $SRC into $DST"
132+ gh pr create \
133+ --repo "$REPO" \
134+ --base "$DST" \
135+ --head "$SRC" \
136+ --title "Release ${{ github.event.inputs.release_version }}" \
137+ --body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST"
0 commit comments