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