Skip to content

Commit f2bb780

Browse files
authored
chore: improvement to github build action (#6495)
1 parent 88cb616 commit f2bb780

File tree

15 files changed

+410
-96
lines changed

15 files changed

+410
-96
lines changed

.circleci/config.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ commands:
297297
- run: *update-fastlane-android
298298
- run:
299299
name: Fastlane Play Store Upload
300-
command: bundle exec fastlane android beta official:<< parameters.official >>
300+
command: bundle exec fastlane android beta_circle_ci official:<< parameters.official >>
301301
working_directory: android
302302

303303
# EXPERIMENTAL ONLY
@@ -314,7 +314,7 @@ commands:
314314
- run: *update-fastlane-android
315315
- run:
316316
name: Fastlane Play Store Upload
317-
command: bundle exec fastlane android internal_app_sharing
317+
command: bundle exec fastlane android internal_app_sharing_circle_ci
318318
working_directory: android
319319

320320
# EXPERIMENTAL ONLY
@@ -332,7 +332,7 @@ commands:
332332
- run: *update-fastlane-android
333333
- run:
334334
name: Fastlane Play Store Upload
335-
command: bundle exec fastlane android production
335+
command: bundle exec fastlane android production_circle_ci
336336
working_directory: android
337337

338338
upload-to-testflight:
@@ -354,7 +354,7 @@ commands:
354354
name: Fastlane Tesflight Upload
355355
command: |
356356
echo $APP_STORE_CONNECT_API_KEY_BASE64 | base64 --decode > ./fastlane/app_store_connect_api_key.p8
357-
bundle exec fastlane ios beta official:<< parameters.official >>
357+
bundle exec fastlane ios beta_circle_ci official:<< parameters.official >>
358358
working_directory: ios
359359
- save_cache: *save-gems-cache
360360

@@ -714,14 +714,4 @@ workflows:
714714
requires:
715715
- android-hold-google-play-beta-official
716716

717-
# Android Automatic Experimental
718-
- android-automatic-build-experimental:
719-
filters:
720-
branches:
721-
only:
722-
- develop
723-
requires:
724-
- lint-testunit
725-
- android-google-play-production-experimental:
726-
requires:
727-
- android-automatic-build-experimental
717+

.github/actions/generate-version-code/action.yml

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
name: Generate Version Code
22
description: Generates version code from GitHub run number
33

4+
inputs:
5+
official:
6+
type: boolean
7+
required: true
8+
os:
9+
type: string
10+
required: true
11+
FASTLANE_GOOGLE_SERVICE_ACCOUNT:
12+
type: string
13+
required: true
14+
APP_STORE_CONNECT_API_KEY_BASE64:
15+
type: string
16+
required: true
17+
MATCH_KEYCHAIN_NAME:
18+
type: string
19+
required: false
20+
MATCH_KEYCHAIN_PASSWORD:
21+
type: string
22+
required: false
23+
MATCH_PASSWORD:
24+
type: string
25+
required: false
26+
APP_STORE_CONNECT_API_KEY_ID:
27+
type: string
28+
required: false
29+
APP_STORE_CONNECT_API_KEY_ISSUER_ID:
30+
type: string
31+
required: false
32+
FASTLANE_REPO_PAT:
33+
type: string
34+
required: false
35+
436
outputs:
537
VERSIONCODE:
638
description: "Generated version code"
@@ -9,16 +41,73 @@ outputs:
941
runs:
1042
using: "composite"
1143
steps:
44+
- name: Set up Xcode
45+
if: ${{ inputs.os == 'ios' }}
46+
uses: maxim-lobanov/setup-xcode@v1
47+
with:
48+
xcode-version: '16.2'
49+
50+
- name: Set up Ruby and Bundler
51+
uses: ruby/setup-ruby@v1
52+
with:
53+
ruby-version: 2.7.7
54+
bundler-cache: true
55+
56+
- name: Install Fastlane
57+
if: ${{ inputs.os == 'android' }}
58+
working-directory: android
59+
run: |
60+
bundle install --path gems
61+
shell: bash
62+
63+
- name: Store the Google service account key
64+
if: ${{ inputs.os == 'android' }}
65+
working-directory: android
66+
run: |
67+
echo "${{ inputs.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}" | base64 --decode > service_account.json
68+
shell: bash
69+
70+
- name: Decode p8
71+
if: ${{ inputs.os == 'ios' }}
72+
run: |
73+
echo ${{ inputs.APP_STORE_CONNECT_API_KEY_BASE64 }} | base64 --decode > ./ios/fastlane/app_store_connect_api_key.p8
74+
shell: bash
75+
76+
- name: Compute VERSIONCODE (iOS)
77+
id: compute-versioncode-ios
78+
if: ${{ inputs.os == 'ios' }}
79+
shell: bash
80+
run: |
81+
VERSIONCODE=$(bundle exec fastlane ios get_testflight_version | grep 'VERSIONCODE=' | cut -d '=' -f2)
82+
echo "LATEST_VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
83+
working-directory: ios
84+
env:
85+
MATCH_KEYCHAIN_NAME: ${{ inputs.MATCH_KEYCHAIN_NAME }}
86+
MATCH_KEYCHAIN_PASSWORD: ${{ inputs.MATCH_KEYCHAIN_PASSWORD }}
87+
MATCH_PASSWORD: ${{ inputs.MATCH_PASSWORD }}
88+
APP_STORE_CONNECT_API_KEY_ID: ${{ inputs.APP_STORE_CONNECT_API_KEY_ID }}
89+
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ inputs.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
90+
FASTLANE_REPO_PAT: ${{ inputs.FASTLANE_REPO_PAT }}
91+
92+
- name: Compute VERSIONCODE (Android)
93+
id: compute-versioncode-android
94+
if: ${{ inputs.os == 'android' }}
95+
shell: bash
96+
run: |
97+
VERSIONCODE=$(bundle exec fastlane android version_code | grep 'VERSIONCODE=' | cut -d '=' -f2)
98+
echo "LATEST_VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
99+
working-directory: android
100+
12101
- name: Compute VERSIONCODE
13102
id: compute
14103
shell: bash
15-
env:
16-
GITHUB_RUN_NUMBER: ${{ github.run_number }}
17104
run: |
18-
# This offset is from CircleCI after we migrated to Github Actions in order to have sequential builds
105+
VERSION_IOS="${{ steps.compute-versioncode-ios.outputs.LATEST_VERSIONCODE }}"
106+
VERSION_ANDROID="${{ steps.compute-versioncode-android.outputs.LATEST_VERSIONCODE }}"
19107
20-
OFFSET=87750
21-
VERSIONCODE=$((OFFSET + GITHUB_RUN_NUMBER))
108+
LATEST_VERSIONCODE="${VERSION_IOS:-$VERSION_ANDROID}"
109+
110+
VERSIONCODE=$((LATEST_VERSIONCODE + 1))
22111
echo "VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
23112
24113
echo "### 📦 Version Code Generated" >> $GITHUB_STEP_SUMMARY

.github/actions/upload-android/action.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
VERSIONCODE:
1414
description: 'Version code for build'
1515
required: true
16+
trigger:
17+
description: 'Trigger for build'
18+
required: true
19+
default: pr
1620

1721
runs:
1822
using: "composite"
@@ -52,10 +56,20 @@ runs:
5256
- name: Fastlane Play Store Upload
5357
working-directory: android
5458
run: |
55-
bundle exec fastlane android beta official:${{ inputs.type == 'official' }}
59+
if [[ ${{ inputs.trigger }} == "pr" ]]; then
60+
bundle exec fastlane android beta official:${{ inputs.type == 'official' }}
61+
fi
62+
if [[ ${{ inputs.trigger }} == "develop" ]] && [[ ${{ inputs.type }} == 'experimental' ]]; then
63+
bundle exec fastlane android experimental_production
64+
fi
65+
if [[ ${{ inputs.trigger }} == "develop" ]] && [[ ${{ inputs.type }} == 'official' ]]; then
66+
bundle exec fastlane android official_open_testing
67+
fi
68+
5669
shell: bash
5770

5871
- name: Leave a comment on PR
72+
if: ${{ inputs.trigger == 'pr' }}
5973
env:
6074
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
6175
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/actions/upload-internal-android/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ inputs:
1313
VERSIONCODE:
1414
description: 'Version code for build'
1515
required: true
16-
16+
trigger:
17+
description: 'Trigger for build'
18+
required: false
19+
default: pr
20+
1721
runs:
1822
using: "composite"
1923
steps:
@@ -75,6 +79,7 @@ runs:
7579
shell: bash
7680

7781
- name: Share Internal App Sharing Link
82+
if: ${{ inputs.trigger == 'pr' }}
7883
env:
7984
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
8085
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/actions/upload-ios/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
GITHUB_TOKEN:
2929
description: 'GitHub token for commenting'
3030
required: true
31+
trigger:
32+
description: 'Trigger for build'
33+
required: false
34+
default: pr
3135

3236
runs:
3337
using: "composite"
@@ -138,6 +142,7 @@ runs:
138142
shell: bash
139143

140144
- name: Comment on PR with TestFlight Info
145+
if: ${{ inputs.trigger == 'pr' }}
141146
env:
142147
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
143148
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/build-android.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ on:
66
type:
77
type: string
88
required: true
9+
trigger:
10+
type: string
11+
required: false
12+
default: pr
913

1014
jobs:
1115
build-hold:
1216
name: Hold
1317
runs-on: ubuntu-latest
18+
if: ${{ inputs.trigger == 'pr' }}
1419
environment: experimental_android_build
1520
steps:
1621
- run: echo "Waiting for manual approval..."
@@ -19,7 +24,7 @@ jobs:
1924
name: Build
2025
runs-on: ubuntu-latest
2126
needs: [build-hold]
22-
if: ${{ inputs.type == 'experimental' }}
27+
if: ${{ inputs.type == 'experimental' && (always() && (needs.build-hold.result == 'success' || needs.build-hold.result == 'skipped')) }}
2328
outputs:
2429
VERSIONCODE: ${{ steps.version.outputs.VERSIONCODE }}
2530
steps:
@@ -32,9 +37,14 @@ jobs:
3237
- name: Generate Version Code
3338
id: version
3439
uses: ./.github/actions/generate-version-code
40+
with:
41+
official: false
42+
os: android
43+
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
3544

3645
- name: Build Android
3746
uses: ./.github/actions/build-android
47+
timeout-minutes: 40
3848
with:
3949
type: 'experimental'
4050
BUGSNAG_KEY: ${{ secrets.BUGSNAG_KEY }}
@@ -49,15 +59,16 @@ jobs:
4959
name: Upload Hold
5060
runs-on: ubuntu-latest
5161
needs: [build-android]
62+
if: ${{ inputs.trigger == 'pr' }}
5263
environment: upload_experimental_android
5364
steps:
5465
- run: echo "Waiting for manual approval..."
5566

5667
upload-android:
5768
name: Upload
5869
runs-on: ubuntu-latest
59-
needs: [upload-hold]
60-
if: ${{ inputs.type == 'experimental' }}
70+
needs: [upload-hold, build-android]
71+
if: ${{ inputs.type == 'experimental' && (always() && (needs.upload-hold.result == 'success' || needs.upload-hold.result == 'skipped') && needs.build-android.result == 'success') }}
6172
steps:
6273
- name: Checkout Repository
6374
uses: actions/checkout@v4
@@ -69,6 +80,7 @@ jobs:
6980
uses: ./.github/actions/upload-android
7081
with:
7182
type: experimental
83+
trigger: ${{ inputs.trigger }}
7284
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
7385
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7486
VERSIONCODE: ${{ needs.build-android.outputs.VERSIONCODE }}
@@ -77,7 +89,7 @@ jobs:
7789
name: Internal Sharing
7890
runs-on: ubuntu-latest
7991
needs: [build-android]
80-
if: ${{ inputs.type == 'experimental' }}
92+
if: ${{ inputs.type == 'experimental' && inputs.trigger == 'pr' }}
8193
steps:
8294
- name: Checkout Repository
8395
uses: actions/checkout@v4
@@ -91,4 +103,4 @@ jobs:
91103
type: experimental
92104
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
93105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94-
VERSIONCODE: ${{ needs.build-android.outputs.VERSIONCODE }}
106+
VERSIONCODE: ${{ needs.build-android.outputs.VERSIONCODE }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build Develop
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- 'develop'
10+
11+
jobs:
12+
run-eslint-and-test:
13+
name: ESLint and Test
14+
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
15+
uses: ./.github/workflows/eslint.yml
16+
17+
android-build-experimental-store:
18+
name: Build Android Experimental
19+
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
20+
uses: ./.github/workflows/build-android.yml
21+
needs: [run-eslint-and-test]
22+
secrets: inherit
23+
with:
24+
type: experimental
25+
trigger: develop
26+
27+
android-build-official-store:
28+
name: Build Android Official
29+
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
30+
uses: ./.github/workflows/build-official-android.yml
31+
needs: [run-eslint-and-test]
32+
secrets: inherit
33+
with:
34+
type: official
35+
trigger: develop
36+
37+
ios-build-experimental-store:
38+
name: Build iOS Experimental
39+
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
40+
uses: ./.github/workflows/build-ios.yml
41+
needs: [run-eslint-and-test]
42+
secrets: inherit
43+
with:
44+
type: experimental
45+
trigger: develop
46+
47+
ios-build-official-store:
48+
name: Build iOS Official
49+
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
50+
uses: ./.github/workflows/build-official-ios.yml
51+
needs: [run-eslint-and-test]
52+
secrets: inherit
53+
with:
54+
type: official
55+
trigger: develop

0 commit comments

Comments
 (0)