-
Notifications
You must be signed in to change notification settings - Fork 55
276 lines (255 loc) · 10.2 KB
/
release-ios-base.yaml
File metadata and controls
276 lines (255 loc) · 10.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
name: release-ios-base
permissions:
id-token: write
contents: read
on:
workflow_call:
inputs:
name:
description: "Name of the project"
required: true
type: string
root-path:
description: "Path of the react-native project"
required: true
type: string
release-type:
description: "Release type of the project (debug/internal/production)"
type: string
project-type:
description: "Type of project (wallet/dapp)"
required: true
type: string
scheme-name:
description: "Scheme name of the project"
required: true
type: string
bundle-id:
description: "Bundle ID of the project"
required: true
type: string
apple-id:
description: "App ID of the project"
required: true
type: string
build-for-simulator:
description: "Build for simulator instead of TestFlight"
required: false
default: false
type: boolean
upload-to-bucket:
description: "Upload to S3"
required: false
default: false
type: boolean
package-manager:
description: "Package manager of the project"
required: false
default: 'yarn'
type: string
testflight-groups:
description: "TestFlight groups"
required: false
type: string
is-expo-project:
description: "Is Expo project"
required: false
default: false
type: boolean
secrets:
sentry-file:
required: true
apple-username:
required: true
apple-key-id:
required: true
apple-key-content:
required: true
apple-issuer-id:
required: true
match-username:
required: true
match-keychain-password:
required: true
match-git-url:
required: true
match-ssh-key:
required: true
google-services-file:
required: false
aws-account-id:
required: false
slack-webhook-url:
required: true
testflight-url:
description: "TestFlight URL of the project"
required: false
env-file:
required: false
jobs:
build:
runs-on: macos-latest-xlarge
steps:
- name: Checkout
uses: actions/checkout@v3
- name: webfactory/ssh-agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.match-ssh-key }}
- name: Setup
uses: ./.github/actions/ci-setup
with:
root-path: ${{ inputs.root-path }}
package-manager: ${{ inputs.package-manager }}
- name: Expo Prebuild
if: ${{ inputs.is-expo-project == true }}
run: |
cd ${{ inputs.root-path }}
npx expo prebuild --platform ios
- name: Set Xcode paths
run: |
# Find the .xcodeproj and .xcworkspace (works for both Expo and non-Expo)
XCODEPROJ=$(find "${{ inputs.root-path }}/ios" -maxdepth 1 -name "*.xcodeproj" -print -quit)
XCWORKSPACE=$(find "${{ inputs.root-path }}/ios" -maxdepth 1 -name "*.xcworkspace" -print -quit)
echo "Found Xcode project: $XCODEPROJ"
echo "Found Xcode workspace: $XCWORKSPACE"
echo "XCODE_PROJECT_PATH=$XCODEPROJ" >> "$GITHUB_ENV"
echo "XCWORKSPACE_PATH=$XCWORKSPACE" >> "$GITHUB_ENV"
- name: Set podfile path
if: ${{ inputs.is-expo-project == false }}
id: podfile-hash
run: |
echo "Root path: ${{ inputs.root-path }}"
echo "Podfile path: ${{ inputs.root-path }}/ios/Podfile.lock"
echo "File exists: $(test -f "${{ inputs.root-path }}/ios/Podfile.lock" && echo "yes" || echo "no")"
echo "podfile_path=${{ inputs.root-path }}/ios/Podfile.lock" >> "$GITHUB_ENV"
- name: Cache pods
id: pods-cache
if: ${{ inputs.is-expo-project == false }}
uses: actions/cache@v4
with:
path: ${{ inputs.root-path }}/ios/Pods
key: ${{ runner.os }}-pods-${{ github.ref_name }}-${{ hashFiles(env.podfile_path) }}
restore-keys: |
${{ runner.os }}-pods-${{ github.ref_name }}-
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: false
- name: Install Gems
run: bundle install
# Create env file
- name: Create env file
run: |
if [ -z "${{ secrets.env-file }}" ]; then
echo "Error: env-file secret is empty or not set"
exit 1
fi
echo "${{ secrets.env-file }}" > ${{ inputs.root-path }}/.env
- name: Copy variant files
run: |
cd ${{ inputs.root-path }}
if [ -f "./scripts/copy-variant-files.sh" ]; then
chmod +x ./scripts/copy-variant-files.sh
./scripts/copy-variant-files.sh ${{ inputs.release-type }}
fi
# Create sentry file
- run: touch ${{ inputs.root-path }}/ios/sentry.properties && echo "${{ secrets.sentry-file }}" >> ${{ inputs.root-path }}/ios/sentry.properties
# Add Google Services file (base64 encoded due to XML structure)
# To encode: base64 -i path/to/GoogleService-Info.plist | pbcopy
- name: Create Google Services file
env:
google-services-file: ${{ secrets.google-services-file }}
if: ${{ env.google-services-file != '' }}
run: echo ${{ env.google-services-file }} | base64 --decode >> ${{ inputs.root-path }}/ios/GoogleService-Info.plist
- name: ${{ inputs.build-for-simulator && 'Build for simulator' || 'Build and Upload to TestFlight' }}
id: build
uses: maierj/fastlane-action@v3.0.0
with:
lane: ${{ inputs.build-for-simulator && 'build_for_simulator' || 'release_testflight' }}
env:
APPLE_ID: ${{ inputs.apple-id }}
APPLE_USERNAME: ${{ secrets.apple-username }}
APPLE_KEY_ID: ${{ secrets.apple-key-id }}
APPLE_KEY_CONTENT: ${{ secrets.apple-key-content }}
APPLE_ISSUER_ID: ${{ secrets.apple-issuer-id }}
BUNDLE_ID: ${{ inputs.bundle-id }}
MATCH_USERNAME: ${{ secrets.match-username }}
MATCH_PASSWORD: ${{ secrets.match-keychain-password }}
MATCH_GIT_URL: ${{ secrets.match-git-url }}
PODFILE_PATH: ${{ inputs.root-path }}/ios/Podfile
SCHEME: ${{ inputs.scheme-name }}
XCODE_PROJECT_PATH: ${{ env.XCODE_PROJECT_PATH }}
XCWORKSPACE_PATH: ${{ env.XCWORKSPACE_PATH }}
PROJECT_TYPE: ${{ inputs.project-type }}
RELEASE_TYPE: ${{ inputs.release-type }}
BRANCH_NAME: ${{ github.ref_name }}
BUILD_FOR_SIMULATOR: ${{ inputs.build-for-simulator }}
TESTFLIGHT_GROUPS: ${{ inputs.testflight-groups }}
- name: Configure AWS credentials
id: aws-creds
if: ${{ inputs.upload-to-bucket == true }}
continue-on-error: true
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
with:
role-to-assume: arn:aws:iam::${{ secrets.aws-account-id }}:role/prod-github-actions-react-native-builds
aws-region: eu-central-1
output-env-credentials: false
output-credentials: true
- name: Upload iOS build to S3
if: ${{ inputs.upload-to-bucket == true }}
id: s3-upload
env:
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ steps.aws-creds.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws-creds.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws-creds.outputs.aws-session-token }}
continue-on-error: true
run: |
aws s3 cp \
./build/${{ inputs.project-type }}-${{ inputs.release-type }}.ipa \
s3://walletconnect.react-native-builds.prod/ios/${{ inputs.release-type }}/${{ inputs.project-type }}-${{ inputs.release-type }}.ipa
- name: Send Slack notification
if: always() && !cancelled()
uses: slackapi/slack-github-action@v2.1.0
with:
webhook: ${{ secrets.slack-webhook-url }}
webhook-type: incoming-webhook
payload: |
{
"text": "iOS Build Report - ${{ inputs.name }} - ${{ inputs.release-type }}",
"blocks": [
{
"type": "header",
"text": { "type": "plain_text", "text": "🍎 iOS Build Report" }
},
{
"type": "section",
"fields": [
{ "type": "mrkdwn", "text": "*Project:*\n`${{ inputs.name }}`" },
{ "type": "mrkdwn", "text": "*Release Type:*\n`${{ inputs.release-type }}`" },
{ "type": "mrkdwn", "text": "*Branch:*\n`${{ github.ref_name }}`" },
{ "type": "mrkdwn", "text": "*Build for Simulator:*\n`${{ inputs.build-for-simulator }}`" }
]
},
{
"type": "section",
"fields": [
{ "type": "mrkdwn", "text": "*Build & TestFlight:*\n`${{ steps.build.outcome == 'success' && '✅ Success' || '❌ Failed' }}`" },
{ "type": "mrkdwn", "text": "*S3 Upload:*\n`${{ steps.s3-upload.outcome == 'success' && '✅ Success' || steps.s3-upload.outcome == 'failure' && '❌ Failed' || '⏭️ Skipped' }}`" },
{ "type": "mrkdwn", "text": "*Overall Status:*\n`${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}`" }
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": { "type": "plain_text", "text": "View Workflow Run" },
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}${{ steps.build.outcome == 'success' && inputs.upload-to-bucket == false && secrets.testflight-url != '' && format(',{{"type":"button","text":{{"type":"plain_text","text":"View in TestFlight"}},"url":"{0}"}}', secrets.testflight-url) || '' }}
]
}
]
}