forked from rainbow-me/rainbow
-
Notifications
You must be signed in to change notification settings - Fork 0
287 lines (250 loc) Β· 11.2 KB
/
Copy pathios-builds.yml
File metadata and controls
287 lines (250 loc) Β· 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: iOS Builds
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
jobs:
# Build iOS simulator app
build-simulator:
name: Simulator
runs-on: macos-15-xlarge
env:
NODE_OPTIONS: "--max-old-space-size=6144"
timeout-minutes: 30
if: github.event.pull_request.draft == false && github.event.pull_request.merged == false
concurrency:
group: ${{ github.workflow }}-simulator-${{ github.ref }}
cancel-in-progress: true
outputs:
artifact-id: ${{ steps.rock-build-simulator.outputs.artifact-id }}
steps:
- name: Checkout repo
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- name: Set Xcode version
run: sudo xcode-select --switch /Applications/Xcode_16.4.app
- name: Setup env key
uses: ./.github/actions/ssh/
with:
name: env
key: ${{ secrets.DEPLOY_PKEY_DOTENV_REPO }}
- name: Setup scripts key
uses: ./.github/actions/ssh/
with:
name: scripts
key: ${{ secrets.DEPLOY_PKEY_SCRIPTS_REPO }}
- name: Setup sandbox key
uses: ./.github/actions/ssh/
with:
name: sandbox
key: ${{ secrets.DEPLOY_PKEY_SANDBOX_REPO }}
- name: Setup env
env:
SSH_AUTH_SOCK: /tmp/ssh_agent_env.sock
run: |
git clone git@github.com:rainbow-me/rainbow-env.git
mv rainbow-env/dotenv .env && rm -rf rainbow-env
echo "0" > is_testing
- name: Setup scripts
env:
CI_SCRIPTS: ${{ secrets.CI_SCRIPTS }}
SSH_AUTH_SOCK: /tmp/ssh_agent_scripts.sock
run: |
eval $CI_SCRIPTS
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache Yarn dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
.yarn/cache
.yarn/install-state.gz
!.eslintcache
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
env:
SSH_AUTH_SOCK: /tmp/ssh_agent_sandbox.sock
run: yarn install && yarn setup
- name: Rock Build - iOS simulator
id: rock-build-simulator
uses: callstackincubator/ios@0bfe6ed5c14bdf3fb88a638d5a19b440e59e845f
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
with:
scheme: Rainbow
destination: simulator
github-token: ${{ secrets.GITHUB_TOKEN }}
configuration: Release
comment-bot: false
re-sign: true
# Build iOS device app
build-device:
name: Device
runs-on: macos-15-xlarge
env:
NODE_OPTIONS: "--max-old-space-size=6144"
timeout-minutes: 30
if: github.event.pull_request.draft == false && github.event.pull_request.merged == false
concurrency:
group: ${{ github.workflow }}-device-${{ github.ref }}
cancel-in-progress: true
outputs:
artifact-id: ${{ steps.rock-build-device.outputs.artifact-id }}
steps:
- name: Checkout repo
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- name: Set Xcode version
run: sudo xcode-select --switch /Applications/Xcode_16.4.app
- name: Setup env key
uses: ./.github/actions/ssh/
with:
name: env
key: ${{ secrets.DEPLOY_PKEY_DOTENV_REPO }}
- name: Setup scripts key
uses: ./.github/actions/ssh/
with:
name: scripts
key: ${{ secrets.DEPLOY_PKEY_SCRIPTS_REPO }}
- name: Setup sandbox key
uses: ./.github/actions/ssh/
with:
name: sandbox
key: ${{ secrets.DEPLOY_PKEY_SANDBOX_REPO }}
- name: Setup code signing key
uses: ./.github/actions/ssh/
with:
name: codesigning
key: ${{ secrets.DEPLOY_PKEY_CODE_SIGNING_REPO }}
- name: Setup env
env:
SSH_AUTH_SOCK: /tmp/ssh_agent_env.sock
run: |
git clone git@github.com:rainbow-me/rainbow-env.git
mv rainbow-env/dotenv .env && rm -rf rainbow-env
echo "0" > is_testing
- name: Setup scripts
env:
CI_SCRIPTS: ${{ secrets.CI_SCRIPTS }}
SSH_AUTH_SOCK: /tmp/ssh_agent_scripts.sock
run: |
eval $CI_SCRIPTS
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache Yarn dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
.yarn/cache
.yarn/install-state.gz
!.eslintcache
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
env:
SSH_AUTH_SOCK: /tmp/ssh_agent_sandbox.sock
run: yarn install && yarn setup
- name: Install Ruby dependencies
run: bundle install
- name: Setup code signing with match
env:
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
SSH_AUTH_SOCK: /tmp/ssh_agent_codesigning.sock
run: |
cd ios
bundle exec fastlane match adhoc --app_identifier me.rainbow,me.rainbow.PriceWidget,me.rainbow.SelectTokenIntent,me.rainbow.ImageNotification,me.rainbow.OpenInRainbow,me.rainbow.ShareWithRainbow --git_url git@github.com:rainbow-me/rainbow-code-signing.git --readonly
- name: Export certificates and provisioning profiles for Rock
id: code-signing
run: |
# Export certificate + private key (identity) to a PKCS#12 file
KEYCHAIN="$HOME/Library/Keychains/login.keychain-db"
P12_OUT="/tmp/cert.p12"
# Export all identities in the keychain as a single PKCS#12 (works fine for CI)
# Note: -t must be 'identities' for pkcs12 with private keys.
security export -k "$KEYCHAIN" -t identities -f pkcs12 -P "${{ secrets.APPLE_BUILD_CERTIFICATE_PASSWORD }}" -o "$P12_OUT"
# Base64 encode for the action input
base64 -i "$P12_OUT" > /tmp/cert_b64.txt
CERT_BASE64=$(cat /tmp/cert_b64.txt)
echo "CERT_BASE64=$CERT_BASE64" >> $GITHUB_OUTPUT
echo "::add-mask::$CERT_BASE64"
# Find and export the provisioning profile
PP_PATH=$(find ~/Library/MobileDevice/Provisioning\ Profiles -name "*.mobileprovision" -exec grep -l "me.rainbow" {} \; | grep -v PriceWidget | grep -v Intent | grep -v Notification | grep -v OpenIn | grep -v ShareWith | head -1)
base64 -i "$PP_PATH" > /tmp/pp_b64.txt
PROFILE_BASE64=$(cat /tmp/pp_b64.txt)
echo "PROFILE_BASE64=$PROFILE_BASE64" >> $GITHUB_OUTPUT
echo "::add-mask::$PROFILE_BASE64"
PROFILE_NAME=$(security cms -D -i "$PP_PATH" | plutil -extract Name raw -)
echo "PROFILE_NAME=$PROFILE_NAME" >> $GITHUB_OUTPUT
echo "::add-mask::$PROFILE_NAME"
PROFILE_UUID=$(security cms -D -i "$PP_PATH" | plutil -extract UUID raw -)
echo "PROFILE_UUID=$PROFILE_UUID" >> $GITHUB_OUTPUT
echo "::add-mask::$PROFILE_UUID"
- name: Update provisioning profiles to AdHoc
run: |
sed -i '' 's/match AppStore/match AdHoc/g' ios/Rainbow.xcodeproj/project.pbxproj
- name: Rock Build - iOS device
id: rock-build-device
uses: callstackincubator/ios@0bfe6ed5c14bdf3fb88a638d5a19b440e59e845f
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
with:
scheme: Rainbow
destination: device
github-token: ${{ secrets.GITHUB_TOKEN }}
configuration: Release
comment-bot: false
re-sign: true
certificate-base64: ${{ steps.code-signing.outputs.CERT_BASE64 }}
certificate-password: ${{ secrets.APPLE_BUILD_CERTIFICATE_PASSWORD }}
provisioning-profile-base64: ${{ steps.code-signing.outputs.PROFILE_BASE64 }}
provisioning-profile-name: ${{ steps.code-signing.outputs.PROFILE_NAME }}
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
rock-build-extra-params: --export-options-plist ExportOptions.adhoc.plist
# Post builds to GitHub after both complete
post-builds:
name: Post Builds
needs: [build-simulator, build-device]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && needs.build-simulator.result == 'success' && needs.build-device.result == 'success'
steps:
- name: Download simulator artifact
run: |
curl -L -H "Authorization: token ${{ github.token }}" -o simulator-artifact.zip "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ needs.build-simulator.outputs.artifact-id }}/zip"
unzip simulator-artifact.zip -d simulator-artifacts
APP_ARCHIVE_PATH=$(find simulator-artifacts -name "*.tar.gz" -print -quit)
tar -xzf "$APP_ARCHIVE_PATH" -C simulator-artifacts
APP_PATH=$(find simulator-artifacts -name "*.app" -type d | head -n 1)
cd "$APP_PATH" && zip -r "${{ github.workspace }}/simulator-app.zip" .
- name: Download device artifact
run: |
curl -L -H "Authorization: token ${{ github.token }}" -o device-artifact.zip "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ needs.build-device.outputs.artifact-id }}/zip"
unzip device-artifact.zip -d device-artifacts
IPA_PATH=$(find device-artifacts -name "*.ipa" | head -n 1)
cp "$IPA_PATH" ./device-app.ipa
- name: Upload builds to AWS S3
env:
AWS_BUCKET: rainbow-app-team-production
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
aws s3 cp "simulator-app.zip" "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.app.zip"
aws s3 cp "device-app.ipa" "s3://${AWS_BUCKET}/${BRANCH_NAME}/${COMMIT_HASH}.ipa"
- name: Post comment to PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
COMMENT="Launch in [simulator](http://localhost:29070/install/http?url=https://app-team.p.rainbow.me/${BRANCH_NAME}/${COMMIT_HASH}.app.zip&platform=ios&destination=simulator) or [device](http://localhost:29070/install/http?url=https://app-team.p.rainbow.me/${BRANCH_NAME}/${COMMIT_HASH}.ipa&platform=ios&destination=device) for ${COMMIT_HASH}"
curl -s -H "Authorization: token $GITHUB_TOKEN" -X POST \
-d "{\"body\":\"$COMMENT\"}" \
"${{ github.event.pull_request.comments_url }}"