10
10
description : " Supported device types are `device`, `emulator`, `simulator`"
11
11
required : true
12
12
default : " simulator"
13
+ distribution :
14
+ description : " Distribution config string, e.g. `local` or `firebase:<appId>`"
15
+ required : true
16
+ default : " local"
13
17
packageManager :
14
18
description : " Binary name of the package manager used in the current repo"
15
19
required : true
54
58
name : android-artifact
55
59
path : ${{ github.event.inputs.projectRoot }}/android/app/build/outputs/apk/debug/app-debug.apk
56
60
if-no-files-found : error
61
+ retention-days : 14
57
62
build-ios :
58
63
name : " Build iOS"
59
64
if : ${{ github.event.inputs.platform == 'ios' }}
62
67
CERTIFICATE_FILE : build-certificate.p12
63
68
KEYCHAIN_FILE : app-signing.keychain-db
64
69
PROVISION_PATH : " Library/MobileDevice/Provisioning Profiles/Provisioning_Profile.mobileprovision"
70
+ XCARCHIVE_FILE : app.xcarchive
65
71
steps :
66
72
- name : Checkout
67
73
uses : actions/checkout@v3
72
78
- name : Install npm dependencies
73
79
run : ${{ github.event.inputs.packageManager }} install
74
80
- name : Install Pods
75
- run : pod install --project-directory=ios
76
- working-directory : ${{ github.event.inputs.projectRoot }}
77
- - name : Disable Clang sanitizers
78
- run : |
79
- # We need to disable Clang sanitizers otherwise the app will crash on
80
- # startup trying to load Clang sanitizer libraries that would only
81
- # exist if Xcode was attached.
82
- xcconfig=node_modules/.generated/ios/ReactTestApp/ReactTestApp.debug.xcconfig
83
- if [[ -f "${xcconfig}" ]]; then
84
- sed -i '' 's/CLANG_ADDRESS_SANITIZER = YES/CLANG_ADDRESS_SANITIZER = NO/g' "${xcconfig}"
85
- sed -i '' 's/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = YES/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = NO/g' "${xcconfig}"
86
- sed -i '' 's/-fsanitize=bounds//g' "${xcconfig}"
87
- fi
81
+ run : pod install --project-directory=ios --verbose
88
82
working-directory : ${{ github.event.inputs.projectRoot }}
89
83
- name : Install Apple signing certificate and provisioning profile
90
84
if : ${{ github.event.inputs.deviceType == 'device' }}
@@ -93,56 +87,35 @@ jobs:
93
87
BUILD_PROVISION_PROFILE_BASE64 : ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
94
88
KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }}
95
89
P12_PASSWORD : ${{ secrets.P12_PASSWORD }}
96
- run : |
97
- # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
98
- mkdir -p "$(dirname "${HOME}/${PROVISION_PATH}")"
99
-
100
- echo -n "${BUILD_CERTIFICATE_BASE64}" | base64 --decode --output "${RUNNER_TEMP}/${CERTIFICATE_FILE}"
101
- echo -n "${BUILD_PROVISION_PROFILE_BASE64}" | base64 --decode --output "${HOME}/${PROVISION_PATH}"
102
-
103
- security create-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
104
- security set-keychain-settings -lut 21600 "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
105
- security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
106
-
107
- security import "${RUNNER_TEMP}/${CERTIFICATE_FILE}" -k "${RUNNER_TEMP}/${KEYCHAIN_FILE}" -t cert -f pkcs12 -P "${P12_PASSWORD}" -A -T '/usr/bin/codesign' -T '/usr/bin/security'
108
- security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}" 1> /dev/null
109
- security list-keychain -d user -s "${RUNNER_TEMP}/${KEYCHAIN_FILE}" login.keychain
90
+ run : npx --prefix . rnx-build-apple install-certificate
110
91
- name : Build iOS app
111
- run : |
112
- if [[ ${{ github.event.inputs.deviceType }} == 'device' ]]; then
113
- destination='generic/platform=iOS'
114
- code_signing=''
115
- else
116
- destination='generic/platform=iOS Simulator'
117
- code_signing='CODE_SIGNING_ALLOWED=NO'
118
- fi
119
- xcworkspace=$(find . -maxdepth 1 -name '*.xcworkspace' -type d | head -1)
120
- xcodebuild -workspace ${xcworkspace} -scheme ${{ github.event.inputs.scheme }} -destination "${destination}" -configuration Debug -derivedDataPath DerivedData ${code_signing} COMPILER_INDEX_STORE_ENABLE=NO build
92
+ run : npx --prefix . rnx-build-apple build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }}
121
93
working-directory : ${{ github.event.inputs.projectRoot }}/ios
122
94
- name : Remove Apple signing certificate and provisioning profile
95
+ # Always run this job step, even if previous ones fail. See also
96
+ # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners
123
97
if : ${{ always() && github.event.inputs.deviceType == 'device' }}
124
- run : |
125
- # Always run this job step, even if previous ones fail. See also
126
- # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners
127
- security delete-keychain "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
128
- rm -f "${RUNNER_TEMP}/${CERTIFICATE_FILE}" "${HOME}/${PROVISION_PATH}"
98
+ run : npx --prefix . rnx-build-apple uninstall-certificate
129
99
- name : Prepare build artifact
100
+ id : prepare-build-artifact
130
101
run : |
131
- output_path=DerivedData/Build/Products
132
- app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1)
133
- # bsdtar corrupts files when archiving due to APFS sparse files. A
134
- # workaround is to use GNU Tar instead. See also:
135
- # - https://github.com/actions/cache/issues/403
136
- # - https://github.com/actions/virtual-environments/issues/2619
137
- gtar -cvf ios-artifact.tar -C "$(dirname ${app})" "$(basename ${app})"
138
- shasum --algorithm 256 ios-artifact.tar
102
+ if [[ ${{ github.event.inputs.distribution }} == 'local' ]]; then
103
+ app=$(find ${XCARCHIVE_FILE}/Products/Applications -maxdepth 1 -name '*.app' -type d | head -1)
104
+ npx --prefix . rnx-build-apple archive ios-artifact.tar "${app}"
105
+ echo 'filename=ios-artifact.tar' >> $GITHUB_OUTPUT
106
+ else
107
+ xcodebuild -exportArchive -archivePath ${XCARCHIVE_FILE} -exportPath export -exportOptionsPlist ExportOptions.plist 2>&1
108
+ ipa=$(find export -maxdepth 1 -name '*.ipa' -type d | head -1)
109
+ echo "filename=${ipa}" >> $GITHUB_OUTPUT
110
+ fi
139
111
working-directory : ${{ github.event.inputs.projectRoot }}/ios
140
112
- name : Upload build artifact
141
113
uses : actions/upload-artifact@v3
142
114
with :
143
115
name : ios-artifact
144
- path : ${{ github.event.inputs.projectRoot }}/ios/ios- artifact.tar
116
+ path : ${{ github.event.inputs.projectRoot }}/ios/${{ steps.prepare-build- artifact.outputs.filename }}
145
117
if-no-files-found : error
118
+ retention-days : 14
146
119
build-macos :
147
120
name : " Build macOS"
148
121
if : ${{ github.event.inputs.platform == 'macos' }}
@@ -157,42 +130,24 @@ jobs:
157
130
- name : Install npm dependencies
158
131
run : ${{ github.event.inputs.packageManager }} install
159
132
- name : Install Pods
160
- run : pod install --project-directory=macos
161
- working-directory : ${{ github.event.inputs.projectRoot }}
162
- - name : Disable Clang sanitizers
163
- run : |
164
- # We need to disable Clang sanitizers otherwise the app will crash on
165
- # startup trying to load Clang sanitizer libraries that would only
166
- # exist if Xcode was attached.
167
- xcconfig=node_modules/.generated/macos/ReactTestApp/ReactTestApp.debug.xcconfig
168
- if [[ -f "${xcconfig}" ]]; then
169
- sed -i '' 's/CLANG_ADDRESS_SANITIZER = YES/CLANG_ADDRESS_SANITIZER = NO/g' "${xcconfig}"
170
- sed -i '' 's/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = YES/CLANG_UNDEFINED_BEHAVIOR_SANITIZER = NO/g' "${xcconfig}"
171
- sed -i '' 's/-fsanitize=bounds//g' "${xcconfig}"
172
- fi
133
+ run : pod install --project-directory=macos --verbose
173
134
working-directory : ${{ github.event.inputs.projectRoot }}
174
135
- name : Build macOS app
175
- run : |
176
- xcworkspace=$(find . -maxdepth 1 -name '*.xcworkspace' -type d | head -1)
177
- xcodebuild -workspace ${xcworkspace} -scheme ${{ github.event.inputs.scheme }} -configuration Debug -derivedDataPath DerivedData CODE_SIGNING_ALLOWED=NO COMPILER_INDEX_STORE_ENABLE=NO build
136
+ run : npx --prefix . rnx-build-apple build-macos --scheme ${{ github.event.inputs.scheme }}
178
137
working-directory : ${{ github.event.inputs.projectRoot }}/macos
179
138
- name : Prepare build artifact
180
139
run : |
181
140
output_path=DerivedData/Build/Products
182
141
app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1)
183
- # bsdtar corrupts files when archiving due to APFS sparse files. A
184
- # workaround is to use GNU Tar instead. See also:
185
- # - https://github.com/actions/cache/issues/403
186
- # - https://github.com/actions/virtual-environments/issues/2619
187
- gtar -cvf macos-artifact.tar -C "$(dirname ${app})" "$(basename ${app})"
188
- shasum --algorithm 256 macos-artifact.tar
142
+ npx --prefix . rnx-build-apple archive macos-artifact.tar "${app}"
189
143
working-directory : ${{ github.event.inputs.projectRoot }}/macos
190
144
- name : Upload build artifact
191
145
uses : actions/upload-artifact@v3
192
146
with :
193
147
name : macos-artifact
194
148
path : ${{ github.event.inputs.projectRoot }}/macos/macos-artifact.tar
195
149
if-no-files-found : error
150
+ retention-days : 14
196
151
build-windows :
197
152
name : " Build Windows"
198
153
if : ${{ github.event.inputs.platform == 'windows' }}
@@ -226,7 +181,7 @@ jobs:
226
181
appx_manifest=$(find ${{ github.event.inputs.architecture }}/Debug -name AppxManifest.xml -type f | head -1)
227
182
app_name=$(basename $(dirname ${appx_manifest}))
228
183
cp ${appx_manifest} AppPackages/${app_name}/*
229
- echo "::set-output name= app-name:: ${app_name}"
184
+ echo "app-name= ${app_name}" >> $GITHUB_OUTPUT
230
185
shell : bash
231
186
working-directory : ${{ github.event.inputs.projectRoot }}/windows
232
187
- name : Upload build artifact
@@ -235,3 +190,25 @@ jobs:
235
190
name : windows-artifact
236
191
path : ${{ github.event.inputs.projectRoot }}/windows/AppPackages/${{ steps.prepare-build-artifact.outputs.app-name }}
237
192
if-no-files-found : error
193
+ retention-days : 14
194
+ distribute :
195
+ name : " Distribute build"
196
+ needs : [build-android, build-ios]
197
+ runs-on : ubuntu-20.04
198
+ if : ${{ github.event.inputs.distribution != 'local' && !cancelled() && !failure() }} # `success()` excludes skipped jobs
199
+ steps :
200
+ - name : Download build artifact
201
+ uses : actions/download-artifact@v3
202
+ with :
203
+ name : ${{ github.event.inputs.platform }}-artifact
204
+ - name : Display structure of build artifact
205
+ run : ls -R
206
+ - name : Upload to Firebase
207
+ if : ${{ startsWith(github.event.inputs.distribution, 'firebase:') }}
208
+ env :
209
+ FIREBASE_APP_ID : ${{ github.event.inputs.distribution }}
210
+ GOOGLE_APPLICATION_CREDENTIALS : credentials.json
211
+ run : |
212
+ artifact=$(find . -maxdepth 1 -type f | head -1)
213
+ echo -n "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" | base64 --decode > ${GOOGLE_APPLICATION_CREDENTIALS}
214
+ npx --package firebase-tools@11 firebase appdistribution:distribute "${artifact}" --app ${FIREBASE_APP_ID:9} --release-notes "${{ github.ref_name }}"
0 commit comments