Skip to content

Commit e1954a1

Browse files
committed
feat: update EAS build to use AAB format and add auto-submit to stores
1 parent 9501ac2 commit e1954a1

File tree

3 files changed

+100
-57
lines changed

3 files changed

+100
-57
lines changed

.github/workflows/eas-build.yml

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
# This workflow is used to trigger a build on EAS.
77
# Can be triggered manually from the actions tab.
88

9-
# This action accepts those inputs:
10-
# `environment`, which is used to generate a build for a specific environment (development, staging, QA, production). We use staging by default.
11-
# `android`, true by default, set to true if you don't want to trigger build for Android.
12-
# `ios`, false by default, set to true if you want to trigger build for IOS.
13-
149
# Before triggering the build, we run a pre-build script to generate the necessary native folders based on the APP_ENV.
1510
# Based on the ANDROID and IOS inputs, we trigger the build for the corresponding platform with the corresponding flags.
1611

@@ -28,33 +23,25 @@
2823
# - Go to Repository Settings > Secrets and variables > Actions > New repository secret
2924
# - Name: NEW_VERSION_NUMBER_PAT
3025
# - Value: The Personal Access Token you created
26+
3127
name: 'EAS Build (Android & IOS) (EAS)'
3228

3329
on:
3430
workflow_dispatch:
3531
inputs:
36-
environment:
32+
platform:
3733
type: choice
38-
description: 'Environment'
39-
required: true
40-
default: 'staging'
34+
description: Platform to build for
4135
options:
42-
- development
43-
- staging
44-
- qa
45-
- production
36+
- android
37+
- ios
4638
new-version:
4739
type: string
48-
description: 'New version (e.g. 1.0.0)'
49-
android:
40+
description: 'New version (e.g. 1.0.0) (optional)'
41+
auto-submit:
5042
type: boolean
51-
description: 'Build for Android'
52-
required: true
53-
default: true
54-
ios:
55-
type: boolean
56-
description: 'Build for iOS'
57-
required: true
43+
description: 'Auto-submit the build to the store'
44+
required: false
5845
default: true
5946

6047
jobs:
@@ -88,28 +75,33 @@ jobs:
8875

8976
build:
9077
needs: validate-new-version
91-
runs-on: ${{ matrix.os }}
78+
runs-on: ${{ inputs.platform == 'ios' && 'macos-latest' || 'ubuntu-latest' }}
9279
permissions:
9380
contents: write
94-
environment: app-${{ inputs.environment }}
95-
strategy:
96-
fail-fast: false
97-
matrix:
98-
platform: [ios, android]
99-
include:
100-
- platform: ios
101-
os: macos-latest
102-
- platform: android
103-
os: ubuntu-latest
81+
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'staging' || github.ref_name == 'qa' && 'qa' || github.ref_name == 'development' && 'development' }}
10482
steps:
83+
- name: Set environment variable
84+
run: |
85+
if [[ "${{ github.ref_name }}" == "main" ]]; then
86+
echo "ENV=production" >> $GITHUB_ENV
87+
elif [[ "${{ github.ref_name }}" == "staging" ]]; then
88+
echo "ENV=staging" >> $GITHUB_ENV
89+
elif [[ "${{ github.ref_name }}" == "qa" ]]; then
90+
echo "ENV=qa" >> $GITHUB_ENV
91+
elif [[ "${{ github.ref_name }}" == "development" ]]; then
92+
echo "ENV=development" >> $GITHUB_ENV
93+
else
94+
echo "Invalid branch: ${{ github.ref_name }}. You can only build for main, staging, qa or development branches."
95+
exit 1
96+
fi
10597
- name: Check if all required secrets exist
10698
run: |
10799
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
108100
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
109101
exit 1
110102
fi
111103
if [ -z "${{ secrets.NEW_VERSION_NUMBER_PAT }}" ]; then
112-
echo "echo "NEW_VERSION_NUMBER_PAT secret not found. Please create a fine-grained Personal Access Token following the instructions in the workflow file.""
104+
echo "NEW_VERSION_NUMBER_PAT secret not found. Please create a fine-grained Personal Access Token following the instructions in the workflow file."
113105
exit 1
114106
fi
115107
@@ -129,7 +121,7 @@ jobs:
129121
uses: ./.github/actions/setup-node-pnpm-install
130122

131123
- name: Create environment file
132-
run: echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ inputs.environment }}
124+
run: echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ env.ENV }}
133125

134126
- name: Update version in package.json
135127
if: inputs.new-version
@@ -146,26 +138,43 @@ jobs:
146138
147139
- name: Setup latest version of Xcode
148140
uses: maxim-lobanov/setup-xcode@v1
149-
if: matrix.platform == 'ios'
141+
if: inputs.platform == 'ios'
150142
with:
151143
xcode-version: latest
152144

153-
- name: ⚙️ Run Prebuild
154-
run: pnpm prebuild:${{ inputs.environment }}
145+
- name: Set Up JDK
146+
uses: actions/setup-java@v3
147+
if: inputs.platform == 'android'
148+
with:
149+
distribution: 'zulu' # See 'Supported distributions' for available options
150+
java-version: '17'
155151

156-
- name: 📱 Run Build for ${{ matrix.platform }}
157-
run: pnpm build:${{ inputs.environment }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ inputs.environment }} for ${{ matrix.platform }}" --local
152+
- name: ⚙️ Run Prebuild
153+
run: pnpm prebuild:${{ env.ENV }}
158154

159-
- name: 📦 Push changes to repository
160-
if: inputs.new-version
155+
- name: 📱 Run Build for ${{ inputs.platform }}
161156
run: |
162-
git push || echo "Skipping push: version was already updated."
163-
164-
- name: Upload ${{ matrix.platform }} Build
157+
pnpm build:${{ env.ENV }}:${{ inputs.platform }} --non-interactive --no-wait --message "Build ${{ env.ENV }} for ${{ inputs.platform }}" --local
158+
if [ "${{ inputs.platform }}" = "android" ]; then
159+
ls -1 "./*.aab" > path.txt
160+
elif [ "${{ inputs.platform }}" = "ios" ]; then
161+
ls -1 "./*.ipa" > path.txt
162+
fi
163+
- name: Upload ${{ inputs.platform }} Build
165164
uses: actions/upload-artifact@v4
166165
with:
167-
name: ${{ matrix.platform }}-build-${{ inputs.environment }}
166+
name: ${{ inputs.platform }}-build-${{ env.ENV }}
168167
path: |
168+
*.apks
169169
*.apk
170170
*.aab
171-
*.ipa
171+
*.ipa
172+
173+
- name: 📱 Submit ${{ inputs.platform }} app to the store
174+
if: inputs.auto-submit
175+
run: pnpm submit:${{ env.ENV }}:mobile --platform=${{ inputs.platform }} --path=$(cat path.txt) --no-wait --non-interactive
176+
177+
- name: 📦 Push changes to repository
178+
if: inputs.new-version
179+
run: |
180+
git push || echo "Skipping push: version was already updated."

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ yarn-error.log
2020

2121
# macOS
2222
.DS_Store
23+
24+
# artifacts
25+
*.apks
2326
*.apk
2427
*.ipa
25-
28+
*.aab
2629

2730
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
2831
# The following patterns were generated by expo-cli

eas.json

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"env": {
2020
"EXPO_NO_DOTENV": "1",
2121
"APP_ENV": "production",
22-
"FLIPPER_DISABLE": "1"
22+
"FLIPPER_DISABLE": "1",
23+
"EAS_NO_DOCTOR": "1"
2324
},
2425
"prebuildCommand": "prebuild --skip-dependency-update react",
2526
"cache": {
@@ -35,13 +36,14 @@
3536
"image": "latest"
3637
},
3738
"android": {
38-
"buildType": "apk",
39+
"buildType": "app-bundle",
3940
"image": "latest"
4041
},
4142
"env": {
4243
"APP_ENV": "staging",
4344
"EXPO_NO_DOTENV": "1",
44-
"FLIPPER_DISABLE": "1"
45+
"FLIPPER_DISABLE": "1",
46+
"EAS_NO_DOCTOR": "1"
4547
},
4648
"prebuildCommand": "prebuild --skip-dependency-update react",
4749
"cache": {
@@ -57,13 +59,14 @@
5759
"image": "latest"
5860
},
5961
"android": {
60-
"buildType": "apk",
62+
"buildType": "app-bundle",
6163
"image": "latest"
6264
},
6365
"env": {
6466
"APP_ENV": "qa",
6567
"EXPO_NO_DOTENV": "1",
66-
"FLIPPER_DISABLE": "1"
68+
"FLIPPER_DISABLE": "1",
69+
"EAS_NO_DOCTOR": "1"
6770
},
6871
"prebuildCommand": "prebuild --skip-dependency-update react",
6972
"cache": {
@@ -73,17 +76,19 @@
7376
"development": {
7477
"autoIncrement": true,
7578
"developmentClient": true,
76-
"distribution": "internal",
79+
"distribution": "store",
7780
"pnpm": "8.15.4",
7881
"ios": {
7982
"image": "latest"
8083
},
8184
"android": {
85+
"buildType": "app-bundle",
8286
"image": "latest"
8387
},
8488
"env": {
8589
"APP_ENV": "development",
86-
"EXPO_NO_DOTENV": "1"
90+
"EXPO_NO_DOTENV": "1",
91+
"EAS_NO_DOCTOR": "1"
8792
},
8893
"prebuildCommand": "prebuild --skip-dependency-update react",
8994
"cache": {
@@ -112,11 +117,37 @@
112117
}
113118
},
114119
"submit": {
115-
"production": {},
120+
"production": {
121+
"ios": {
122+
"ascAppId": ""
123+
},
124+
"android": {
125+
"releaseStatus": "draft"
126+
}
127+
},
116128
"staging": {
117129
"ios": {
118130
"ascAppId": "6745524568"
131+
},
132+
"android": {
133+
"releaseStatus": "draft"
134+
}
135+
},
136+
"qa": {
137+
"ios": {
138+
"ascAppId": "6745527331"
139+
},
140+
"android": {
141+
"releaseStatus": "draft"
142+
}
143+
},
144+
"development": {
145+
"ios": {
146+
"ascAppId": ""
147+
},
148+
"android": {
149+
"releaseStatus": "draft"
119150
}
120151
}
121152
}
122-
}
153+
}

0 commit comments

Comments
 (0)