Skip to content

Commit 278f7fc

Browse files
authored
Distribute aab with fastlane #77
ref DEV-2149
2 parents 9316756 + 4c706c6 commit 278f7fc

File tree

8 files changed

+419
-53
lines changed

8 files changed

+419
-53
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,18 @@ jobs:
4040
- uses: ruby/setup-ruby@v1
4141
with:
4242
bundler-cache: true
43-
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#java
44-
- name: Set java version
45-
run: |
46-
echo "JAVA_HOME=$JAVA_HOME_21_arm64" >> $GITHUB_ENV
4743
- uses: subosito/flutter-action@v2
4844
with:
4945
# This has to be kept in sync with .tool-versions
5046
flutter-version: '3.27.1'
5147
channel: 'stable'
5248
# This action takes 1m30s to finish. Enable cache to make it shorter.
5349
cache: true
54-
- run: echo "$ANDROID_HOME/tools/bin" >> $GITHUB_PATH
5550
- run: make example-flutter-pub-get
5651
- run: make example-flutter-test
5752
- run: make example-flutter-analyze
5853
- run: make example-dart-format
59-
- run: flutter build apk --debug
60-
working-directory: ./example
54+
- run: make example-build-unsigned-android-aab
6155

6256
deploy-docs:
6357
runs-on: ubuntu-24.04
@@ -127,48 +121,38 @@ jobs:
127121
deploy-android:
128122
runs-on: macos-14
129123
needs: ["test-android"]
130-
# We cannot build in PRs because secrets are not available in PRs.
131-
if: ${{ github.repository == 'authgear/authgear-sdk-flutter' && github.ref == 'refs/heads/main' }}
132-
defaults:
133-
run:
134-
working-directory: "./example"
124+
if: ${{ github.repository == 'authgear/authgear-sdk-flutter' }}
135125
steps:
136126
- uses: actions/checkout@v4
137-
- uses: actions/setup-node@v4
127+
- uses: ruby/setup-ruby@v1
138128
with:
139-
node-version-file: "./.tool-versions"
140-
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#java
141-
- name: Set java version
142-
run: |
143-
echo "JAVA_HOME=$JAVA_HOME_21_arm64" >> $GITHUB_ENV
144-
- run: npm install -g appcenter-cli
129+
bundler-cache: true
145130
- uses: subosito/flutter-action@v2
146131
with:
147132
# This has to be kept in sync with .tool-versions
148133
flutter-version: '3.27.1'
149134
channel: 'stable'
150135
# This action takes 1m30s to finish. Enable cache to make it shorter.
151136
cache: true
152-
- run: flutter pub get
153-
- run: flutter test
154-
- run: flutter analyze --no-fatal-infos
155-
- run: dart format --set-exit-if-changed lib
156-
- name: Prepare key store
157-
env:
158-
ANDROID_KEY_STORE_BASE64: ${{ secrets.ANDROID_KEY_STORE_BASE64 }}
159-
run: |
160-
KEY_STORE_PATH=./android/app/keystore.jks
161-
162-
echo -n "$ANDROID_KEY_STORE_BASE64" | base64 --decode -o "$KEY_STORE_PATH"
163-
- name: Build .apk
137+
- run: make example-flutter-pub-get
138+
- run: make example-flutter-test
139+
- run: make example-flutter-analyze
140+
- run: make example-dart-format
141+
- name: Build aab
164142
env:
143+
STORE_BASE64: ${{ secrets.ANDROID_KEY_STORE_BASE64 }}
165144
STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
166145
KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
167146
KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
168147
run: |
169-
BUILD_NUMBER=$(date +%s)
170-
flutter build apk --build-number $BUILD_NUMBER -P STORE_PASSWORD="$STORE_PASSWORD" -P KEY_PASSWORD="$KEY_PASSWORD" -P KEY_ALIAS="$KEY_ALIAS"
171-
- name: Distribute to App Center
148+
export STORE_FILE="$RUNNER_TEMP/upload_key.jks"
149+
echo -n "$STORE_BASE64" | base64 --decode -o "$STORE_FILE"
150+
make example-build-android-aab
151+
- name: Upload aab
152+
if: ${{ github.ref == 'refs/heads/main' }}
172153
env:
173-
APPCENTER_ACCESS_TOKEN: ${{ secrets.ANDROID_APPCENTER_ACCESS_TOKEN }}
174-
run: appcenter distribute release --debug --silent --file "./build/app/outputs/flutter-apk/app-release.apk" --group "Collaborators" --app "Oursky/Authgear-Demo-Flutter-Android"
154+
GOOGLE_SERVICE_ACCOUNT_KEY_JSON_BASE64: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY_JSON_BASE64 }}
155+
run: |
156+
export GOOGLE_SERVICE_ACCOUNT_KEY_JSON_FILE="$RUNNER_TEMP/google_service_account_key.json"
157+
echo -n "$GOOGLE_SERVICE_ACCOUNT_KEY_JSON_BASE64" | base64 --decode -o "$GOOGLE_SERVICE_ACCOUNT_KEY_JSON_FILE"
158+
make example-upload-android-aab

Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,33 @@ example-pod-install:
2020

2121
.PHONY: example-build-unsigned-ios-app
2222
example-build-unsigned-ios-app:
23-
bundle exec fastlane runner_build_ios_app skip_codesigning:1
23+
bundle exec fastlane ios runner_build_ios_app skip_codesigning:1
2424

2525
.PHONY: example-build-ios-app
2626
example-build-ios-app:
27-
bundle exec fastlane runner_build_ios_app FLUTTER_BUILD_NAME:1.0 FLUTTER_BUILD_NUMBER:$(shell date +%s)
27+
bundle exec fastlane ios runner_build_ios_app FLUTTER_BUILD_NAME:1.0 FLUTTER_BUILD_NUMBER:$(shell date +%s)
2828

2929
.PHONY: example-upload-ios-app
3030
example-upload-ios-app:
31-
bundle exec fastlane upload_ios_app ipa:./build/Release/iOS/Runner/Runner.ipa
31+
bundle exec fastlane ios upload_ios_app ipa:./build/Release/iOS/Runner/Runner.ipa
32+
33+
.PHONY: example-build-unsigned-android-aab
34+
example-build-unsigned-android-aab:
35+
cd ./example/android; ./gradlew :app:bundleDebug
36+
37+
.PHONY: example-build-android-aab
38+
example-build-android-aab:
39+
bundle exec fastlane android build_aab \
40+
VERSION_CODE:$(shell date +%s) \
41+
STORE_FILE:$(STORE_FILE) \
42+
STORE_PASSWORD:$(STORE_PASSWORD) \
43+
KEY_ALIAS:$(KEY_ALIAS) \
44+
KEY_PASSWORD:$(KEY_PASSWORD)
45+
46+
.PHONY: example-upload-android-aab
47+
example-upload-android-aab:
48+
bundle exec fastlane android upload_aab \
49+
json_key:$(GOOGLE_SERVICE_ACCOUNT_KEY_JSON_FILE)
3250

3351
.PHONY: sdk-flutter-pub-get
3452
sdk-flutter-pub-get:

example/android/.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
gradle-wrapper.jar
2-
/.gradle
1+
/.gradle/
32
/captures/
4-
/gradlew
5-
/gradlew.bat
63
/local.properties
74
GeneratedPluginRegistrant.java
85

example/android/app/build.gradle

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,35 @@ android {
2424
}
2525

2626
defaultConfig {
27-
applicationId = "com.authgear.exampleapp.flutter"
27+
applicationId = "com.authgear.sdk.exampleapp.flutter"
2828
// minSdkVersion flutter.minSdkVersion
2929
// 21 is required to use androidx.security
3030
minSdk = 21
3131
targetSdk = flutter.targetSdkVersion
32-
versionCode = flutter.versionCode
32+
if (project.hasProperty("VERSION_CODE")) {
33+
versionCode = Integer.parseInt(project.findProperty("VERSION_CODE"))
34+
} else {
35+
versionCode = flutter.versionCode
36+
}
3337
versionName = flutter.versionName
3438
}
3539

3640
signingConfigs {
37-
release {
38-
storeFile file("keystore.jks")
39-
storePassword project.ext.has("STORE_PASSWORD") ? project.ext["STORE_PASSWORD"] : ""
40-
keyAlias project.ext.has("KEY_ALIAS") ? project.ext["KEY_ALIAS"] : ""
41-
keyPassword project.ext.has("KEY_PASSWORD") ? project.ext["KEY_PASSWORD"] : ""
41+
if (project.hasProperty("STORE_FILE")) {
42+
release {
43+
storeFile file(project.findProperty("STORE_FILE"))
44+
storePassword project.findProperty("STORE_PASSWORD")
45+
keyAlias project.findProperty("KEY_ALIAS")
46+
keyPassword project.findProperty("KEY_PASSWORD")
47+
}
4248
}
4349
}
4450

4551
buildTypes {
4652
release {
47-
signingConfig signingConfigs.release
53+
if (project.hasProperty("STORE_FILE")) {
54+
signingConfig signingConfigs.release
55+
}
4856
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
4957
}
5058
}
60.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)