mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1---
2name: Bundle and Deploy EAS Update
3
4on:
5 push:
6 branches:
7 - main
8 - hailey/eas-fab
9 workflow_dispatch:
10 inputs:
11 channel:
12 type: choice
13 description: Deployment channel to use
14 options:
15 - testflight
16 - production
17 runtimeVersion:
18 type: string
19 description: Runtime version (in x.x.x format) that this update is for
20 required: true
21
22jobs:
23 bundleDeploy:
24 name: Bundle and Deploy EAS Update
25 runs-on: ubuntu-latest
26 concurrency:
27 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-deploy
28 cancel-in-progress: true
29 outputs:
30 changes-detected: ${{ steps.fingerprint.outputs.includes-changes }}
31
32 steps:
33 - name: Check for EXPO_TOKEN
34 run: >
35 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
36 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"
37 exit 1
38 fi
39
40 # Validate the version if one is supplied. This should generally happen if the update is for a production client
41 - name: 🧐 Validate version
42 if: ${{ inputs.runtimeVersion }}
43 run: |
44 if [ -z "${{ inputs.runtimeVersion }}" ]; then
45 [[ "${{ inputs.runtimeVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "Version is valid" || exit 1
46 fi
47
48 - name: ⬇️ Checkout
49 uses: actions/checkout@v4
50 with:
51 fetch-depth: 0
52
53 - name: ⬇️ Fetch commits from base branch
54 if: ${{ github.ref != 'refs/heads/main' }}
55 run: git fetch origin main:main --depth 100
56
57 - name: 🔧 Setup Node
58 uses: actions/setup-node@v4
59 with:
60 node-version-file: .nvmrc
61 cache: yarn
62
63 - name: 📷 Check fingerprint and install dependencies
64 id: fingerprint
65 uses: bluesky-social/github-actions/fingerprint-native@main
66 with:
67 profile: ${{ inputs.channel || 'testflight' }}
68 previous-commit-tag: ${{ inputs.runtimeVersion }}
69
70 - name: Lint check
71 run: yarn lint
72
73 - name: Lint lockfile
74 run: yarn lockfile-lint
75
76 - name: Prettier check
77 run: yarn prettier --check "**/*.{ts,tsx,js}" --experimental-cli
78
79 - name: 🔤 Compile translations
80 run: yarn intl:build 2>&1 | tee i18n.log
81
82 - name: Check for i18n compilation errors
83 run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
84
85 - name: Type check
86 run: yarn typecheck
87
88 - name: 🔨 Setup EAS
89 uses: expo/expo-github-action@v8
90 if: ${{ !steps.fingerprint.outputs.includes-changes }}
91 with:
92 expo-version: latest
93 eas-version: latest
94 token: ${{ secrets.EXPO_TOKEN }}
95
96 - name: ⛏️ Setup Expo
97 if: ${{ !steps.fingerprint.outputs.includes-changes }}
98 run: yarn global add eas-cli-local-build-plugin
99
100 - name: 🪛 Setup jq
101 if: ${{ !steps.fingerprint.outputs.includes-changes }}
102 uses: dcarbone/install-jq-action@v2
103
104 - name: ✏️ Write environment variables
105 if: ${{ !steps.fingerprint.outputs.includes-changes }}
106 run: |
107 export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
108 echo "${{ secrets.ENV_TOKEN }}" > .env
109 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
110 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
111 echo "BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
112 echo "$json" > google-services.json
113
114 - name: Setup Sentry vars for build-time injection
115 id: sentry
116 run: |
117 echo "SENTRY_DIST=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
118 echo "SENTRY_RELEASE=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
119
120 - name: 🏗️ Create Bundle
121 if: ${{ !steps.fingerprint.outputs.includes-changes }}
122 run: |
123 SENTRY_DIST=${{ steps.sentry.outputs.SENTRY_DIST }} SENTRY_RELEASE=${{ steps.sentry.outputs.SENTRY_RELEASE }} SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_DSN=${{ secrets.SENTRY_DSN }} EXPO_PUBLIC_ENV="${{ inputs.channel || 'testflight' }}" yarn export-ios
124 mv ./dist ./ios-dist
125 sed -i 's/"react-native-mmkv": "\^2\.12\.2"/"react-native-mmkv": "^3.3.0"/' package.json
126 yarn install
127 SENTRY_DIST=${{ steps.sentry.outputs.SENTRY_DIST }} SENTRY_RELEASE=${{ steps.sentry.outputs.SENTRY_RELEASE }} SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_DSN=${{ secrets.SENTRY_DSN }} EXPO_PUBLIC_ENV="${{ inputs.channel || 'testflight' }}" yarn export-android
128 mv ./dist ./android-dist
129
130
131 - name: 📦 Package Bundle and 🚀 Deploy
132 if: ${{ !steps.fingerprint.outputs.includes-changes }}
133 run: yarn use-build-number bash scripts/bundleUpdate.sh
134 env:
135 DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }}
136 RUNTIME_VERSION: ${{ inputs.runtimeVersion }}
137 CHANNEL_NAME: ${{ inputs.channel || 'testflight' }}
138
139 - name: ⬇️ Restore Cache
140 id: get-base-commit
141 uses: actions/cache@v4
142 if: ${{ !steps.fingerprint.outputs.includes-changes }}
143 with:
144 path: most-recent-testflight-commit.txt
145 key: most-recent-testflight-commit
146
147 - name: ✏️ Write commit hash to cache
148 if: ${{ !steps.fingerprint.outputs.includes-changes }}
149 run: echo ${{ github.sha }} > most-recent-testflight-commit.txt
150
151 # GitHub actions are horrible so let's just copy paste this in
152 buildIfNecessaryIOS:
153 name: Build and Submit iOS
154 runs-on: macos-15
155 concurrency:
156 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-ios
157 cancel-in-progress: true
158 needs: [bundleDeploy]
159 # Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
160 # available here
161 if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
162 steps:
163 - name: Check for EXPO_TOKEN
164 run: >
165 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
166 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"
167 exit 1
168 fi
169
170 - name: ⬇️ Checkout
171 uses: actions/checkout@v4
172 with:
173 fetch-depth: 5
174
175 - name: 🔧 Setup Node
176 uses: actions/setup-node@v4
177 with:
178 node-version-file: .nvmrc
179 cache: yarn
180
181 - name: 🔨 Setup EAS
182 uses: expo/expo-github-action@v8
183 with:
184 expo-version: latest
185 eas-version: latest
186 token: ${{ secrets.EXPO_TOKEN }}
187
188 - name: ⛏️ Setup EAS local builds
189 run: yarn global add eas-cli-local-build-plugin
190
191 - name: ⚙️ Install dependencies
192 run: yarn install
193
194 - uses: maxim-lobanov/setup-xcode@v1
195 with:
196 xcode-version: '16.2'
197
198 - name: ☕️ Setup Cocoapods
199 uses: maxim-lobanov/setup-cocoapods@v1
200 with:
201 version: 1.14.3
202
203 - name: 💾 Cache Pods
204 uses: actions/cache@v3
205 id: pods-cache
206 with:
207 path: ./ios/Pods
208 # We'll use the yarn.lock for our hash since we don't yet have a Podfile.lock. Pod versions will not
209 # change unless the yarn version changes as well.
210 key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
211
212 - name: 🔤 Compile translations
213 run: yarn intl:build
214
215 - name: ✏️ Write environment variables
216 run: |
217 echo "${{ secrets.ENV_TOKEN }}" > .env
218 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
219 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
220 echo "BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
221 echo "${{ secrets.GOOGLE_SERVICES_TOKEN }}" > google-services.json
222
223 - name: 🏗️ EAS Build
224 run: yarn use-build-number-with-bump eas build -p ios --profile testflight --local --output build.ipa --non-interactive
225
226 - name: 🚀 Deploy
227 run: eas submit -p ios --non-interactive --path build.ipa
228
229 - name: ⬇️ Restore Cache
230 id: get-base-commit
231 uses: actions/cache@v4
232 if: ${{ inputs.channel == 'testflight' }}
233 with:
234 path: most-recent-testflight-commit.txt
235 key: most-recent-testflight-commit
236
237 - name: ✏️ Write commit hash to cache
238 if: ${{ inputs.channel == 'testflight' }}
239 run: echo ${{ github.sha }} > most-recent-testflight-commit.txt
240
241 buildIfNecessaryAndroid:
242 name: Build and Submit Android
243 runs-on: ubuntu-latest
244 concurrency:
245 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-build-android
246 cancel-in-progress: false
247 needs: [bundleDeploy]
248 # Gotta check if its NOT '[]' because any md5 hash in the outputs is detected as a possible secret and won't be
249 # available here
250 if: ${{ inputs.channel != 'production' && needs.bundleDeploy.outputs.changes-detected }}
251
252 steps:
253 - name: Check for EXPO_TOKEN
254 run: >
255 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
256 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"
257 exit 1
258 fi
259
260 - name: ⬇️ Checkout
261 uses: actions/checkout@v4
262 with:
263 fetch-depth: 5
264
265 - name: 🔧 Setup Node
266 uses: actions/setup-node@v4
267 with:
268 node-version-file: .nvmrc
269 cache: yarn
270
271 - name: 🔨 Setup EAS
272 uses: expo/expo-github-action@v8
273 with:
274 expo-version: latest
275 eas-version: latest
276 token: ${{ secrets.EXPO_TOKEN }}
277
278 - name: ⛏️ Setup EAS local builds
279 run: yarn global add eas-cli-local-build-plugin
280
281 - uses: actions/setup-java@v4
282 with:
283 distribution: 'temurin'
284 java-version: '17'
285
286 - name: "Use upgraded MMKV for Fabric"
287 run: |
288 sed -i 's/"react-native-mmkv": "\^2\.12\.2"/"react-native-mmkv": "^3.3.0"/' package.json
289
290 - name: ⚙️ Install dependencies
291 run: yarn install
292
293 - name: 🔤 Compile translations
294 run: yarn intl:build
295
296 - name: ✏️ Write environment variables
297 run: |
298 export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
299 echo "${{ secrets.ENV_TOKEN }}" > .env
300 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse --short HEAD)" >> .env
301 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
302 echo "BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
303 echo "$json" > google-services.json
304
305 - name: 🏗️ EAS Build
306 run: yarn use-build-number-with-bump eas build -p android --profile testflight-android --local --output build.apk --non-interactive
307
308 - name: ⏰ Get a timestamp
309 id: timestamp
310 uses: nanzm/get-time-action@master
311 with:
312 format: 'MM-DD-HH-mm-ss'
313
314 - name: 🚀 Upload Artifact
315 id: upload-artifact
316 uses: actions/upload-artifact@v4
317 with:
318 retention-days: 30
319 compression-level: 0
320 name: build-${{ steps.timestamp.outputs.time }}.apk
321 path: build.apk
322
323 - name: 🔔 Notify Slack
324 uses: slackapi/slack-github-action@v1.25.0
325 with:
326 payload: |
327 {
328 "text": "Android build is ready for testing. Download the artifact here: ${{ steps.upload-artifact.outputs.artifact-url }}"
329 }
330 env:
331 SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLIENT_ALERT_WEBHOOK }}
332 SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
333
334 - name: ⬇️ Restore Cache
335 id: get-base-commit
336 uses: actions/cache@v4
337 if: ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
338 with:
339 path: most-recent-testflight-commit.txt
340 key: most-recent-testflight-commit
341
342 - name: ✏️ Write commit hash to cache
343 if: ${{ inputs.channel != 'testflight' && inputs.channel != 'production' }}
344 run: echo ${{ github.sha }} > most-recent-testflight-commit.txt