Skip to content

Commit ce17de7

Browse files
Use altool to distribute
1 parent 61d3959 commit ce17de7

File tree

4 files changed

+276
-138
lines changed

4 files changed

+276
-138
lines changed

.github/workflows/ci.yaml

Lines changed: 110 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: ruby/setup-ruby@v1
2828
with:
2929
bundler-cache: false
30-
- run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
30+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
3131
- run: bundle install
3232
- run: npm ci
3333
- run: npm ci
@@ -79,16 +79,9 @@ jobs:
7979
- uses: actions/setup-node@v4
8080
with:
8181
node-version-file: "./.tool-versions"
82-
- uses: ruby/setup-ruby@v1
83-
with:
84-
bundler-cache: false
85-
- run: npm ci
86-
- run: npm run build
87-
- working-directory: ./example/reactnative
88-
run: yarn
89-
- name: Build unsigned APK
90-
working-directory: ./example/reactnative/android
91-
run: ./gradlew :app:assembleRelease
82+
- run: make sdk-build
83+
- run: make react-native-npm-ci
84+
- run: make react-native-build-unsigned-apk
9285

9386
test_capacitor_ios:
9487
runs-on: macos-14
@@ -100,42 +93,27 @@ jobs:
10093
- uses: ruby/setup-ruby@v1
10194
with:
10295
bundler-cache: false
103-
- run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
104-
- run: npm ci
105-
- run: npm run build
106-
- working-directory: ./example/capacitor
107-
run: npm ci
108-
- working-directory: ./example/capacitor
109-
run: npm run build
110-
- working-directory: ./example/capacitor
111-
run: npx cap sync
112-
- name: Run xcodebuild
113-
working-directory: ./example/capacitor/ios/App
114-
run: xcodebuild -quiet -workspace App.xcworkspace -scheme App -sdk iphonesimulator build
96+
- run: bundle install
97+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
98+
- run: make sdk-build
99+
- run: make capacitor-npm-ci
100+
- run: make capacitor-build-js
101+
- run: make capacitor-build-ios-simulator
102+
115103
test_capacitor_android:
116104
runs-on: macos-14
117105
steps:
118106
- uses: actions/checkout@v4
119107
- uses: actions/setup-node@v4
120108
with:
121109
node-version-file: "./.tool-versions"
122-
- uses: ruby/setup-ruby@v1
123-
with:
124-
bundler-cache: false
125-
- run: npm ci
126-
- run: npm run build
127-
- working-directory: ./example/capacitor
128-
run: npm ci
129-
- working-directory: ./example/capacitor
130-
run: npm run build
131-
- working-directory: ./example/capacitor
132-
run: npx cap sync
133-
- name: Build unsigned APK
134-
working-directory: ./example/capacitor/android
135-
run: ./gradlew :app:assembleRelease
110+
- run: make sdk-build
111+
- run: make capacitor-npm-ci
112+
- run: make capacitor-build-js
113+
- run: make capacitor-build-unsigned-apk
136114

137115
react_native_ios:
138-
if: ${{ github.repository == 'authgear/authgear-sdk-js' && github.ref == 'refs/heads/master' && github.event_name == 'push' }}
116+
if: ${{ github.repository == 'authgear/authgear-sdk-js' }}
139117
needs: test
140118
# When we change the runner image, the ruby version will change too.
141119
# We need to update .tool-versions to make them the same.
@@ -149,18 +127,11 @@ jobs:
149127
- uses: ruby/setup-ruby@v1
150128
with:
151129
bundler-cache: false
152-
- run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
153-
- run: npm install -g appcenter-cli
154-
- run: npm ci
155-
- run: npm run build
156-
- working-directory: ./example/reactnative
157-
run: yarn
158-
- working-directory: ./example/reactnative
159-
# Install cocoapods from the Gemfile
160-
run: bundle install
161-
- working-directory: ./example/reactnative
162-
# Run the specific cocoapods
163-
run: bundle exec pod install --project-directory=ios
130+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
131+
- run: make sdk-build
132+
- run: make react-native-npm-ci
133+
- run: make react-native-bundle-install
134+
- run: make react-native-pod-install
164135
- name: Install the Apple certificate and provisioning profile
165136
env:
166137
IOS_CERTIFICATE_BASE64: ${{ secrets.REACT_NATIVE_IOS_CERTIFICATE_BASE64 }}
@@ -182,28 +153,48 @@ jobs:
182153
183154
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
184155
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
185-
- name: Set CFBundleVersion
186-
working-directory: ./example/reactnative/ios
156+
- name: Install App Store Connect API key
157+
env:
158+
IOS_API_KEY_BASE64: ${{ secrets.IOS_API_KEY_BASE64 }}
159+
IOS_API_KEY_ID: ${{ secrets.IOS_API_KEY_ID }}
187160
run: |
188-
BUILD_NUMBER=$(date +%s)
189-
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $BUILD_NUMBER" ./reactNativeExample/Info.plist
161+
API_KEY_PATH=$RUNNER_TEMP/AuthKey_${IOS_API_KEY_ID}.p8
162+
echo -n "$IOS_API_KEY_BASE64" | base64 --decode -o $API_KEY_PATH
163+
- run: make react-native-set-CFBundleVersion
190164
- name: Run xcodebuild archive
191-
working-directory: ./example/reactnative/ios
192-
run: xcodebuild -workspace reactNativeExample.xcworkspace -scheme reactNativeExample -configuration Release -archivePath "$RUNNER_TEMP/reactNativeExample.xcarchive" archive
165+
run: |
166+
export REACT_NATIVE_ARCHIVE_PATH="$RUNNER_TEMP/reactNativeExample.xcarchive"
167+
make react-native-archive
193168
- name: Run xcodebuild -exportArchive
194-
working-directory: ./example/reactnative/ios
195-
run: xcodebuild -exportArchive -archivePath "$RUNNER_TEMP/reactNativeExample.xcarchive" -exportPath "$RUNNER_TEMP/reactNativeExample.export" -exportOptionsPlist "./ExportOptions.plist"
196-
- name: Distribute to App Center
169+
run: |
170+
export REACT_NATIVE_ARCHIVE_PATH="$RUNNER_TEMP/reactNativeExample.xcarchive"
171+
export REACT_NATIVE_EXPORT_PATH="$RUNNER_TEMP/reactNativeExample.export"
172+
make react-native-export-archive
173+
- name: Validate .ipa
197174
env:
198-
APPCENTER_ACCESS_TOKEN: ${{ secrets.REACT_NATIVE_IOS_APPCENTER_ACCESS_TOKEN }}
199-
run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/reactNativeExample.export/reactNativeExample.ipa" --store "App Store Connect Users" --app "Oursky/Authgear-demo-RN-iOS" --release-notes "no release notes"
175+
API_ISSUER: ${{ secrets.IOS_API_KEY_ISSUER }}
176+
API_KEY: ${{ secrets.IOS_API_KEY_ID }}
177+
run: |
178+
export API_PRIVATE_KEYS_DIR="$RUNNER_TEMP"
179+
export IPA_PATH="$RUNNER_TEMP/reactNativeExample.export/reactNativeExample.ipa"
180+
make validate-app
181+
- name: Upload to TestFlight
182+
if: ${{ github.ref == 'refs/heads/master' }}
183+
env:
184+
API_ISSUER: ${{ secrets.IOS_API_KEY_ISSUER }}
185+
API_KEY: ${{ secrets.IOS_API_KEY_ID }}
186+
run: |
187+
export API_PRIVATE_KEYS_DIR="$RUNNER_TEMP"
188+
export IPA_PATH="$RUNNER_TEMP/reactNativeExample.export/reactNativeExample.ipa"
189+
make upload-app
200190
- name: Clean up keychain and provisioning profile
201191
if: ${{ always() }}
202192
run: |
203193
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
204194
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
195+
205196
react_native_android:
206-
if: ${{ github.repository == 'authgear/authgear-sdk-js' && github.ref == 'refs/heads/master' && github.event_name == 'push' }}
197+
if: ${{ github.repository == 'authgear/authgear-sdk-js' }}
207198
needs: test
208199
# When we change the runner image, the available Android build tools versions will also change.
209200
# We need to update build.gradle too.
@@ -217,46 +208,33 @@ jobs:
217208
- uses: ruby/setup-ruby@v1
218209
with:
219210
bundler-cache: false
220-
- run: npm install -g appcenter-cli
221-
- run: npm ci
222-
- run: npm run build
223-
- working-directory: ./example/reactnative
224-
run: yarn
225-
- name: Set versionCode
226-
run: |
227-
VERSION_CODE=$(date +%s)
228-
sed -I "" "s/versionCode 1/versionCode $VERSION_CODE/" ./example/reactnative/android/app/build.gradle
229-
- name: Build unsigned APK
230-
working-directory: ./example/reactnative/android
231-
run: ./gradlew :app:assembleRelease
211+
- run: make sdk-build
212+
- run: make react-native-npm-ci
213+
- run: make react-native-set-versionCode
214+
- run: make react-native-build-unsigned-apk
232215
- name: Install keystore
233216
env:
234217
ANDROID_KEYSTORE_BASE64: ${{ secrets.REACT_NATIVE_ANDROID_KEYSTORE_BASE64 }}
235218
run: |
236219
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
237220
echo -n "$ANDROID_KEYSTORE_BASE64" | base64 --decode -o $KEYSTORE_PATH
238-
- name: Run zipalign
239-
run: |
240-
"$ANDROID_HOME/build-tools/33.0.3/zipalign" -c -v 4 ./example/reactnative/android/app/build/outputs/apk/release/app-release-unsigned.apk
221+
- run: make react-native-zipalign
241222
- name: Run apksigner
242223
env:
243224
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.REACT_NATIVE_ANDROID_KEYSTORE_PASSWORD }}
244225
ANDROID_KEY_ALIAS: ${{ secrets.REACT_NATIVE_ANDROID_KEY_ALIAS }}
245226
ANDROID_KEY_PASSWORD: ${{ secrets.REACT_NATIVE_ANDROID_KEY_PASSWORD }}
246227
run: |
247-
"$ANDROID_HOME/build-tools/33.0.3/apksigner" sign \
248-
--ks $RUNNER_TEMP/keystore.jks \
249-
--ks-key-alias "$ANDROID_KEY_ALIAS" \
250-
--ks-pass "pass:$ANDROID_KEYSTORE_PASSWORD" \
251-
--key-pass "pass:$ANDROID_KEY_PASSWORD" \
252-
--out ./example/reactnative/android/app/build/outputs/apk/release/app-release-signed.apk \
253-
./example/reactnative/android/app/build/outputs/apk/release/app-release-unsigned.apk
228+
export ANDROID_KEYSTORE_PATH="$RUNNER_TEMP/keystore.jks"
229+
make react-native-apksigner
254230
- name: Distribute to App Center
231+
if: ${{ github.ref == 'refs/heads/master' }}
255232
env:
256233
APPCENTER_ACCESS_TOKEN: ${{ secrets.REACT_NATIVE_ANDROID_APPCENTER_ACCESS_TOKEN }}
257234
run: appcenter distribute release --debug --silent --file ./example/reactnative/android/app/build/outputs/apk/release/app-release-signed.apk --group "Collaborators" --app "Oursky/Authgear-demo-RN-Android" --release-notes "no release notes"
235+
258236
capacitor_ios:
259-
if: ${{ github.repository == 'authgear/authgear-sdk-js' && github.ref == 'refs/heads/master' && github.event_name == 'push' }}
237+
if: ${{ github.repository == 'authgear/authgear-sdk-js' }}
260238
needs: test
261239
runs-on: macos-14
262240
steps:
@@ -267,18 +245,11 @@ jobs:
267245
- uses: ruby/setup-ruby@v1
268246
with:
269247
bundler-cache: false
270-
- run: sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
271-
- run: npm install -g appcenter-cli
272-
- run: npm ci
273-
- run: npm run build
274-
- working-directory: ./example/capacitor
275-
run: npm ci
276-
- working-directory: ./example/capacitor
277-
run: npm audit
278-
- working-directory: ./example/capacitor
279-
run: npm run build
280-
- working-directory: ./example/capacitor
281-
run: npx cap sync
248+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
249+
- run: make sdk-build
250+
- run: make capacitor-npm-ci
251+
- run: make capacitor-npm-audit
252+
- run: make capacitor-build-js
282253
- name: Install the Apple certificate and provisioning profile
283254
env:
284255
IOS_CERTIFICATE_BASE64: ${{ secrets.CAPACITOR_IOS_CERTIFICATE_BASE64 }}
@@ -300,28 +271,48 @@ jobs:
300271
301272
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
302273
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
303-
- name: Set CFBundleVersion
304-
working-directory: ./example/capacitor/ios/App
274+
- name: Install App Store Connect API key
275+
env:
276+
IOS_API_KEY_BASE64: ${{ secrets.IOS_API_KEY_BASE64 }}
277+
IOS_API_KEY_ID: ${{ secrets.IOS_API_KEY_ID }}
305278
run: |
306-
BUILD_NUMBER=$(date +%s)
307-
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $BUILD_NUMBER" ./App/Info.plist
279+
API_KEY_PATH=$RUNNER_TEMP/AuthKey_${IOS_API_KEY_ID}.p8
280+
echo -n "$IOS_API_KEY_BASE64" | base64 --decode -o $API_KEY_PATH
281+
- run: make capacitor-set-CFBundleVersion
308282
- name: Run xcodebuild archive
309-
working-directory: ./example/capacitor/ios/App
310-
run: xcodebuild -workspace App.xcworkspace -scheme App -configuration Release -archivePath "$RUNNER_TEMP/App.xcarchive" archive
283+
run: |
284+
export CAPACITOR_ARCHIVE_PATH="$RUNNER_TEMP/App.xcarchive"
285+
make capacitor-archive
311286
- name: Run xcodebuild -exportArchive
312-
working-directory: ./example/capacitor/ios/App
313-
run: xcodebuild -exportArchive -archivePath "$RUNNER_TEMP/App.xcarchive" -exportPath "$RUNNER_TEMP/App.export" -exportOptionsPlist "./ExportOptions.plist"
314-
- name: Distribute to App Center
287+
run: |
288+
export CAPACITOR_ARCHIVE_PATH="$RUNNER_TEMP/App.xcarchive"
289+
export CAPACITOR_EXPORT_PATH="$RUNNER_TEMP/App.export"
290+
make capacitor-exportArchive
291+
- name: Validate .ipa
315292
env:
316-
APPCENTER_ACCESS_TOKEN: ${{ secrets.CAPACITOR_IOS_APPCENTER_ACCESS_TOKEN }}
317-
run: appcenter distribute release --debug --silent --file "$RUNNER_TEMP/App.export/App.ipa" --store "App Store Connect Users" --app "Oursky/Authgear-Demo-Capacitor-iOS" --release-notes "no release notes"
293+
API_ISSUER: ${{ secrets.IOS_API_KEY_ISSUER }}
294+
API_KEY: ${{ secrets.IOS_API_KEY_ID }}
295+
run: |
296+
export API_PRIVATE_KEYS_DIR="$RUNNER_TEMP"
297+
export IPA_PATH="$RUNNER_TEMP/App.export/App.ipa"
298+
make validate-app
299+
- name: Upload to TestFlight
300+
if: ${{ github.ref == 'refs/heads/master' }}
301+
env:
302+
API_ISSUER: ${{ secrets.IOS_API_KEY_ISSUER }}
303+
API_KEY: ${{ secrets.IOS_API_KEY_ID }}
304+
run: |
305+
export API_PRIVATE_KEYS_DIR="$RUNNER_TEMP"
306+
export IPA_PATH="$RUNNER_TEMP/App.export/App.ipa"
307+
make upload-app
318308
- name: Clean up keychain and provisioning profile
319309
if: ${{ always() }}
320310
run: |
321311
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
322312
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
313+
323314
capacitor_android:
324-
if: ${{ github.repository == 'authgear/authgear-sdk-js' && github.ref == 'refs/heads/master' && github.event_name == 'push' }}
315+
if: ${{ github.repository == 'authgear/authgear-sdk-js' }}
325316
needs: test
326317
runs-on: macos-14
327318
steps:
@@ -333,46 +324,29 @@ jobs:
333324
with:
334325
bundler-cache: false
335326
- run: npm install -g appcenter-cli
336-
- run: npm ci
337-
- run: npm run build
338-
- working-directory: ./example/capacitor
339-
run: npm ci
340-
- working-directory: ./example/capacitor
341-
run: npm audit
342-
- working-directory: ./example/capacitor
343-
run: npm run build
344-
- working-directory: ./example/capacitor
345-
run: npx cap sync
346-
- name: Set versionCode
347-
run: |
348-
VERSION_CODE=$(date +%s)
349-
sed -I "" "s/versionCode 1/versionCode $VERSION_CODE/" ./example/capacitor/android/app/build.gradle
350-
- name: Build unsigned APK
351-
working-directory: ./example/capacitor/android
352-
run: ./gradlew :app:assembleRelease
327+
- run: make sdk-build
328+
- run: make capacitor-npm-ci
329+
- run: make capacitor-npm-audit
330+
- run: make capacitor-build-js
331+
- run: make capacitor-set-versionCode
332+
- run: make capacitor-build-unsigned-apk
353333
- name: Install keystore
354334
env:
355335
ANDROID_KEYSTORE_BASE64: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_BASE64 }}
356336
run: |
357337
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
358338
echo -n "$ANDROID_KEYSTORE_BASE64" | base64 --decode -o $KEYSTORE_PATH
359-
- name: Run zipalign
360-
run: |
361-
"$ANDROID_HOME/build-tools/35.0.1/zipalign" -c -v 4 ./example/capacitor/android/app/build/outputs/apk/release/app-release-unsigned.apk
339+
- run: make capacitor-zipalign
362340
- name: Run apksigner
363341
env:
364342
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_PASSWORD }}
365343
ANDROID_KEY_ALIAS: ${{ secrets.CAPACITOR_ANDROID_KEY_ALIAS }}
366344
ANDROID_KEY_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEY_PASSWORD }}
367345
run: |
368-
"$ANDROID_HOME/build-tools/35.0.1/apksigner" sign \
369-
--ks $RUNNER_TEMP/keystore.jks \
370-
--ks-key-alias "$ANDROID_KEY_ALIAS" \
371-
--ks-pass "pass:$ANDROID_KEYSTORE_PASSWORD" \
372-
--key-pass "pass:$ANDROID_KEY_PASSWORD" \
373-
--out ./example/capacitor/android/app/build/outputs/apk/release/app-release-signed.apk \
374-
./example/capacitor/android/app/build/outputs/apk/release/app-release-unsigned.apk
346+
export ANDROID_KEYSTORE_PATH="$RUNNER_TEMP/keystore.jks"
347+
make capacitor-apksigner
375348
- name: Distribute to App Center
349+
if: ${{ github.ref == 'refs/heads/master' }}
376350
env:
377351
APPCENTER_ACCESS_TOKEN: ${{ secrets.CAPACITOR_ANDROID_APPCENTER_ACCESS_TOKEN }}
378352
run: appcenter distribute release --debug --silent --file ./example/capacitor/android/app/build/outputs/apk/release/app-release-signed.apk --group "Collaborators" --app "Oursky/Authgear-Demo-Capacitor-Android" --release-notes "no release notes"

0 commit comments

Comments
 (0)