Skip to content

Commit 9316756

Browse files
authored
Switch to use fastlane to distribute iOS app #76
ref DEV-2149
2 parents 355924e + 48fc815 commit 9316756

File tree

13 files changed

+378
-144
lines changed

13 files changed

+378
-144
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_PATH: "vendor/bundle"

.github/workflows/ci.yaml

Lines changed: 45 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,33 @@ on:
1313
jobs:
1414
test-ios:
1515
runs-on: macos-14
16-
defaults:
17-
run:
18-
working-directory: "./example"
1916
steps:
2017
- uses: actions/checkout@v4
21-
- uses: actions/setup-node@v4
18+
- uses: ruby/setup-ruby@v1
2219
with:
23-
node-version-file: "./.tool-versions"
24-
# Xcode_16.2.app is available, but it does not have any simulator pre-installed.
25-
# So it is not really usable.
26-
# Let's use Xcode_16.1.app instead.
27-
- run: sudo xcode-select -s /Applications/Xcode_16.1.app/Contents/Developer
20+
bundler-cache: true
21+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
2822
- uses: subosito/flutter-action@v2
2923
with:
3024
# This has to be kept in sync with .tool-versions
3125
flutter-version: '3.27.1'
3226
channel: 'stable'
3327
# This action takes 1m30s to finish. Enable cache to make it shorter.
3428
cache: true
35-
- run: flutter pub get
36-
- run: flutter test
37-
- run: flutter analyze --no-fatal-infos
38-
- run: dart format --set-exit-if-changed lib
39-
- run: flutter build ipa --no-codesign
29+
- run: make example-flutter-pub-get
30+
- run: make example-flutter-test
31+
- run: make example-flutter-analyze
32+
- run: make example-dart-format
33+
- run: make example-pod-install
34+
- run: make example-build-unsigned-ios-app
4035

4136
test-android:
4237
runs-on: macos-14
43-
defaults:
44-
run:
45-
working-directory: "./example"
4638
steps:
4739
- uses: actions/checkout@v4
48-
- uses: actions/setup-node@v4
40+
- uses: ruby/setup-ruby@v1
4941
with:
50-
node-version-file: "./.tool-versions"
42+
bundler-cache: true
5143
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#java
5244
- name: Set java version
5345
run: |
@@ -60,11 +52,12 @@ jobs:
6052
# This action takes 1m30s to finish. Enable cache to make it shorter.
6153
cache: true
6254
- run: echo "$ANDROID_HOME/tools/bin" >> $GITHUB_PATH
63-
- run: flutter pub get
64-
- run: flutter test
65-
- run: flutter analyze --no-fatal-infos
66-
- run: dart format --set-exit-if-changed lib
55+
- run: make example-flutter-pub-get
56+
- run: make example-flutter-test
57+
- run: make example-flutter-analyze
58+
- run: make example-dart-format
6759
- run: flutter build apk --debug
60+
working-directory: ./example
6861

6962
deploy-docs:
7063
runs-on: ubuntu-24.04
@@ -78,89 +71,58 @@ jobs:
7871
channel: 'stable'
7972
# This action takes 1m30s to finish. Enable cache to make it shorter.
8073
cache: true
81-
- run: flutter pub get
82-
- run: flutter test
83-
- run: flutter analyze --no-fatal-infos
84-
- run: dart format --set-exit-if-changed lib
74+
- run: make sdk-flutter-pub-get
75+
- run: make sdk-flutter-test
76+
- run: make sdk-flutter-analyze
77+
- run: make sdk-dart-format
8578
# Install the latest dartdoc to avoid a bug
8679
# See DEVELOPER.md
8780
- run: flutter pub global activate dartdoc
88-
if: ${{ github.ref == 'refs/heads/main' }}
8981
- run: flutter pub global run dartdoc
90-
if: ${{ github.ref == 'refs/heads/main' }}
9182
- name: Deploy docs to gh-pages
9283
uses: peaceiris/actions-gh-pages@v3
93-
if: ${{ github.ref == 'refs/heads/main' }}
84+
if: ${{ github.repository == 'authgear/authgear-sdk-flutter' && github.ref == 'refs/heads/main' }}
9485
with:
9586
github_token: ${{ secrets.GITHUB_TOKEN }}
9687
publish_dir: ./doc/api
9788

9889
deploy-ios:
9990
runs-on: macos-14
10091
needs: ["test-ios"]
101-
# We cannot build in PRs because secrets are not available in PRs.
102-
if: ${{ github.repository == 'authgear/authgear-sdk-flutter' && github.ref == 'refs/heads/main' }}
103-
defaults:
104-
run:
105-
working-directory: "./example"
92+
if: ${{ github.repository == 'authgear/authgear-sdk-flutter' }}
10693
steps:
10794
- uses: actions/checkout@v4
108-
- uses: actions/setup-node@v4
95+
- uses: ruby/setup-ruby@v1
10996
with:
110-
node-version-file: "./.tool-versions"
111-
# Xcode_16.2.app is available, but it does not have any simulator pre-installed.
112-
# So it is not really usable.
113-
# Let's use Xcode_16.1.app instead.
114-
- run: sudo xcode-select -s /Applications/Xcode_16.1.app/Contents/Developer
115-
- run: npm install -g appcenter-cli
97+
bundler-cache: true
98+
- run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
11699
- uses: subosito/flutter-action@v2
117100
with:
118101
# This has to be kept in sync with .tool-versions
119102
flutter-version: '3.27.1'
120103
channel: 'stable'
121104
# This action takes 1m30s to finish. Enable cache to make it shorter.
122105
cache: true
123-
- run: flutter pub get
124-
- run: flutter test
125-
- run: flutter analyze --no-fatal-infos
126-
- run: dart format --set-exit-if-changed lib
127-
- name: Prepare certificate and provisioning profile
128-
env:
129-
IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }}
130-
IOS_CERTIFICATE_BASE64: ${{ secrets.IOS_CERTIFICATE_BASE64 }}
131-
IOS_PROVISIONING_PROFILE_BASE64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }}
132-
IOS_KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
133-
run: |
134-
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
135-
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
136-
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
137-
138-
# import certificate and provisioning profile from secrets
139-
echo -n "$IOS_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
140-
141-
echo -n "$IOS_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH
142-
143-
# create temporary keychain
144-
security create-keychain -p "$IOS_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
145-
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
146-
security unlock-keychain -p "$IOS_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
147-
148-
# import certificate to keychain
149-
security import $CERTIFICATE_PATH -P "$IOS_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
150-
security set-key-partition-list -S apple-tool:,apple: -k "$IOS_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
151-
security list-keychain -d user -s $KEYCHAIN_PATH
152-
153-
# apply provisioning profile
154-
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
155-
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
156-
- name: Build .ipa
157-
run: |
158-
BUILD_NUMBER=$(date +%s)
159-
flutter build ipa --export-options-plist ./exportOptions.plist --build-number $BUILD_NUMBER
160-
- name: Distribute to App Center
161-
env:
162-
APPCENTER_ACCESS_TOKEN: ${{ secrets.IOS_APPCENTER_ACCESS_TOKEN }}
163-
run: appcenter distribute release --debug --silent --file "./build/ios/ipa/Authgear Flutter.ipa" --store "App Store Connect Users" --app "Oursky/Authgear-Demo-Flutter-iOS" --release-notes "no release notes"
106+
- run: make example-flutter-pub-get
107+
- run: make example-flutter-test
108+
- run: make example-flutter-analyze
109+
- run: make example-dart-format
110+
- uses: authgear/gh-actions-install-apple-certificate-and-provisioning-profile@v1
111+
with:
112+
certificate_base64: ${{ secrets.IOS_CERTIFICATE_BASE64 }}
113+
certificate_password: ${{ secrets.IOS_CERTIFICATE_PASSWORD }}
114+
provisioning_profile_base64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }}
115+
- uses: authgear/gh-actions-create-fastlane-api-key-json-file@v1
116+
with:
117+
api_key_id: ${{ secrets.IOS_API_KEY_ID }}
118+
api_key_issuer: ${{ secrets.IOS_API_KEY_ISSUER }}
119+
api_key_base64: ${{ secrets.IOS_API_KEY_BASE64 }}
120+
output_path: ./build/fastlane-api-key.json
121+
- run: make example-pod-install
122+
- run: make example-build-ios-app
123+
- name: Upload to TestFlight
124+
if: ${{ github.ref == 'refs/heads/main' }}
125+
run: make example-upload-ios-app
164126

165127
deploy-android:
166128
runs-on: macos-14

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*.iws
1616
.idea/
1717

18+
# xcode
19+
xcuserdata/
20+
xcshareddata/
21+
1822
# The .vscode folder contains launch configuration and tasks you configure in
1923
# VS Code which you may wish to be included in version control, so this line
2024
# is commented out by default.
@@ -27,3 +31,8 @@
2731
.dart_tool/
2832
.packages
2933
build/
34+
35+
# fastlane
36+
/vendor/
37+
/fastlane/README.md
38+
/fastlane/report.xml

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
flutter 3.27.1-stable
22
nodejs 20.18.1
3-
ruby 3.3.6
3+
ruby 3.3.7

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
source 'https://rubygems.org'
22

3-
gem "cocoapods", "1.16.0"
3+
gem "cocoapods", "~> 1.16"
4+
gem "fastlane", "~> 2.227"

0 commit comments

Comments
 (0)