-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
221 lines (198 loc) · 8.12 KB
/
build-rc-auto.yml
File metadata and controls
221 lines (198 loc) · 8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
##############################################################################################
#
# This Workflow is responsible for triggering release candidate builds (iOS & Android).
# It runs automatically on every commit pushed to a release branch that has an open PR.
#
# Rolling builds: when a new run starts for the same release branch, any queued or
# in-progress run of this workflow for that branch is cancelled (same behavior as
# Bitrise "Rolling builds" / "Abort running builds" for one branch + one workflow).
#
# Version bump runs once (update-latest-build-version.yml), then iOS and Android
# builds are triggered in parallel via runway-ota-build-core.yml (skip_version_bump).
#
# The RC build comment includes an AI-generated test plan (inline with collapsible sections).
#
##############################################################################################
name: Auto RC builds
on:
push:
branches:
- 'release/*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
actions: write
id-token: write
jobs:
validate-and-find-pr:
name: Validate branch and find PR
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.extract-version.outputs.semver }}
has-pr: ${{ steps.find-pr.outputs.has-pr }}
branch-name: ${{ steps.extract-version.outputs.branch-name }}
pr-number: ${{ steps.find-pr.outputs.pr-number }}
permissions:
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Extract semver from branch name
id: extract-version
run: |
BRANCH_NAME="${{ github.ref_name }}"
echo "Checking branch: $BRANCH_NAME"
echo "branch-name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
# Validate branch matches release/x.y.z format (semantic versioning)
if [[ "$BRANCH_NAME" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
VERSION="${BRANCH_NAME#release/}"
echo "Valid release branch detected: $BRANCH_NAME (version: $VERSION)"
echo "semver=$VERSION" >> "$GITHUB_OUTPUT"
else
echo "Branch '$BRANCH_NAME' does not match release/x.y.z pattern. Skipping."
echo "semver=" >> "$GITHUB_OUTPUT"
exit 1
fi
- name: Find associated PR
id: find-pr
run: |
BRANCH_NAME="${{ github.ref_name }}"
echo "Looking for PR with head branch: $BRANCH_NAME"
# Find PRs where the head branch matches our release branch
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' || echo "")
if [[ -z "$PR_NUMBER" ]]; then
echo "No PR found for branch $BRANCH_NAME. Skipping."
echo "has-pr=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Found PR #$PR_NUMBER - proceeding with RC build"
echo "pr-number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "has-pr=true" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update_rc_build_version:
name: Update RC build version
uses: ./.github/workflows/update-latest-build-version.yml
needs: validate-and-find-pr
if: needs.validate-and-find-pr.outputs.has-pr == 'true'
permissions:
contents: write
id-token: write
with:
base-branch: ${{ needs.validate-and-find-pr.outputs.branch-name }}
secrets:
PR_TOKEN: ${{ secrets.PR_TOKEN }}
trigger-ios-rc-build:
name: Trigger iOS RC Build
uses: ./.github/workflows/runway-ota-build-core.yml
needs:
- validate-and-find-pr
- update_rc_build_version
if: needs.validate-and-find-pr.outputs.has-pr == 'true'
with:
platform: ios
source_branch: ${{ needs.update_rc_build_version.outputs.commit-hash }}
skip_version_bump: true
secrets: inherit
trigger-android-rc-build:
name: Trigger Android RC Build
uses: ./.github/workflows/runway-ota-build-core.yml
needs:
- validate-and-find-pr
- update_rc_build_version
if: needs.validate-and-find-pr.outputs.has-pr == 'true'
with:
platform: android
source_branch: ${{ needs.update_rc_build_version.outputs.commit-hash }}
skip_version_bump: true
secrets: inherit
post-rc-build-comment:
name: Post RC Build Comment with Test Plan
runs-on: ubuntu-latest
needs:
- validate-and-find-pr
- trigger-ios-rc-build
- trigger-android-rc-build
if: always() && needs.trigger-ios-rc-build.result == 'success' && needs.trigger-android-rc-build.result == 'success' && needs.validate-and-find-pr.outputs.pr-number != ''
environment: release-ci
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.validate-and-find-pr.outputs.branch-name }}
fetch-depth: 50
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Post RC Build Comment with Test Plan
run: node -r esbuild-register scripts/build-announce/index.ts
timeout-minutes: 8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ needs.validate-and-find-pr.outputs.pr-number }}
SEMVER: ${{ needs.validate-and-find-pr.outputs.semver }}
IOS_BUILD_NUMBER: ${{ needs.trigger-ios-rc-build.outputs.ios_version_code }}
ANDROID_BUILD_NUMBER: ${{ needs.trigger-android-rc-build.outputs.android_version_code }}
BUILD_PIPELINE_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
# AI Provider keys for test plan generation
E2E_CLAUDE_API_KEY: ${{ secrets.E2E_CLAUDE_API_KEY }}
E2E_OPENAI_API_KEY: ${{ secrets.E2E_OPENAI_API_KEY }}
E2E_GEMINI_API_KEY: ${{ secrets.E2E_GEMINI_API_KEY }}
- name: Upload test plan JSON to GitHub Pages
if: always()
continue-on-error: true
run: |
VERSION="${{ needs.validate-and-find-pr.outputs.semver }}"
JSON_FILE="release-test-plan.json"
# Check if JSON file was generated
if [ ! -f "$JSON_FILE" ]; then
echo "No test plan JSON file found, skipping upload"
exit 0
fi
# Save JSON to temp
cp "$JSON_FILE" "/tmp/test-plan-${VERSION}.json"
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Fetch gh-pages branch or create it
git fetch origin gh-pages:gh-pages 2>/dev/null || echo "gh-pages doesn't exist yet"
# Switch to gh-pages
if git checkout gh-pages 2>/dev/null; then
echo "Switched to existing gh-pages branch"
else
git checkout --orphan gh-pages
git rm -rf . 2>/dev/null || true
git clean -fd 2>/dev/null || true
fi
# Create test-plans directory and copy JSON
mkdir -p test-plans
cp "/tmp/test-plan-${VERSION}.json" "test-plans/"
# Commit and push
git add test-plans/
git commit -m "Add test plan JSON for RC ${VERSION}" || echo "No changes to commit"
git push origin gh-pages
slack-notification:
name: Slack RC Notification
needs:
- validate-and-find-pr
- trigger-ios-rc-build
- trigger-android-rc-build
if: always() && needs.trigger-ios-rc-build.result == 'success' && needs.trigger-android-rc-build.result == 'success'
uses: ./.github/workflows/slack-rc-notification.yml
with:
source_branch: ${{ needs.validate-and-find-pr.outputs.branch-name }}
semver: ${{ needs.trigger-ios-rc-build.outputs.semantic_version }}
ios_build_number: ${{ needs.trigger-ios-rc-build.outputs.ios_version_code }}
android_build_number: ${{ needs.trigger-android-rc-build.outputs.android_version_code }}
secrets: inherit