Skip to content

Commit bded794

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

File tree

3 files changed

+101
-46
lines changed

3 files changed

+101
-46
lines changed

.github/workflows/eas-build.yml

Lines changed: 57 additions & 36 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,29 @@
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:
37-
type: choice
38-
description: 'Environment'
39-
required: true
40-
default: 'staging'
41-
options:
42-
- development
43-
- staging
44-
- qa
45-
- production
32+
# environment:
33+
# type: choice
34+
# description: 'Environment'
35+
# required: true
36+
# default: 'staging'
37+
# options:
38+
# - development
39+
# - staging
40+
# - qa
41+
# - production
4642
new-version:
4743
type: string
48-
description: 'New version (e.g. 1.0.0)'
49-
android:
44+
description: 'New version (e.g. 1.0.0) (optional)'
45+
auto-submit:
5046
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
47+
description: 'Auto-submit the build to the store'
48+
required: false
5849
default: true
5950

6051
jobs:
@@ -91,7 +82,7 @@ jobs:
9182
runs-on: ${{ matrix.os }}
9283
permissions:
9384
contents: write
94-
environment: app-${{ inputs.environment }}
85+
environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'staging' || github.ref_name == 'qa' && 'qa' || github.ref_name == 'development' && 'development' }}
9586
strategy:
9687
fail-fast: false
9788
matrix:
@@ -102,14 +93,28 @@ jobs:
10293
- platform: android
10394
os: ubuntu-latest
10495
steps:
96+
- name: Set environment variable
97+
run: |
98+
if [[ "${{ github.ref_name }}" == "main" ]]; then
99+
echo "ENV=production" >> $GITHUB_ENV
100+
elif [[ "${{ github.ref_name }}" == "staging" ]]; then
101+
echo "ENV=staging" >> $GITHUB_ENV
102+
elif [[ "${{ github.ref_name }}" == "qa" ]]; then
103+
echo "ENV=qa" >> $GITHUB_ENV
104+
elif [[ "${{ github.ref_name }}" == "development" ]]; then
105+
echo "ENV=development" >> $GITHUB_ENV
106+
else
107+
echo "Invalid branch: ${{ github.ref_name }}. You can only build for main, staging, qa or development branches."
108+
exit 1
109+
fi
105110
- name: Check if all required secrets exist
106111
run: |
107112
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
108113
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"
109114
exit 1
110115
fi
111116
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.""
117+
echo "NEW_VERSION_NUMBER_PAT secret not found. Please create a fine-grained Personal Access Token following the instructions in the workflow file.""
113118
exit 1
114119
fi
115120
@@ -129,7 +134,7 @@ jobs:
129134
uses: ./.github/actions/setup-node-pnpm-install
130135

131136
- name: Create environment file
132-
run: echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ inputs.environment }}
137+
run: echo "${{ secrets.ENVIRONMENT_FILE }}" > .env.${{ env.ENV }}
133138

134139
- name: Update version in package.json
135140
if: inputs.new-version
@@ -150,22 +155,38 @@ jobs:
150155
with:
151156
xcode-version: latest
152157

158+
- name: Set Up JDK
159+
uses: actions/setup-java@v3
160+
if: matrix.platform == 'android'
161+
with:
162+
distribution: 'zulu' # See 'Supported distributions' for available options
163+
java-version: '17'
164+
153165
- name: ⚙️ Run Prebuild
154-
run: pnpm prebuild:${{ inputs.environment }}
166+
run: pnpm prebuild:${{ env.ENV }}
155167

156168
- 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
158-
159-
- name: 📦 Push changes to repository
160-
if: inputs.new-version
161169
run: |
162-
git push || echo "Skipping push: version was already updated."
163-
170+
pnpm build:${{ env.ENV }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ env.ENV }} for ${{ matrix.platform }}" --local
171+
if [ "${{ matrix.platform }}" = "android" ]; then
172+
ls -1 "./*.aab" > path.txt
173+
elif [ "${{ matrix.platform }}" = "ios" ]; then
174+
ls -1 "./*.ipa" > path.txt
175+
fi
164176
- name: Upload ${{ matrix.platform }} Build
165177
uses: actions/upload-artifact@v4
166178
with:
167-
name: ${{ matrix.platform }}-build-${{ inputs.environment }}
179+
name: ${{ matrix.platform }}-build-${{ env.ENV }}
168180
path: |
181+
*.apks
169182
*.apk
170183
*.aab
171-
*.ipa
184+
*.ipa
185+
186+
- name: 📱 Submit ${{ matrix.platform }} app to the store
187+
run: pnpm submit:${{ env.ENV }}:mobile --platform=${{ matrix.platform }} --path=$(cat path.txt) --no-wait --non-interactive
188+
189+
- name: 📦 Push changes to repository
190+
if: inputs.new-version
191+
run: |
192+
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)