From cd31266de5ae70eb5cb0e470b3f9a6a7ab712884 Mon Sep 17 00:00:00 2001
From: Andri Joos <andri@joos.io>
Date: Tue, 19 Nov 2024 23:13:02 +0100
Subject: [PATCH] split android

---
 android/universal_apk.gitlab-ci.yml   | 33 +++++++++++++++++++++++++++
 flutter/flutter-android.gitlab-ci.yml | 22 +-----------------
 2 files changed, 34 insertions(+), 21 deletions(-)
 create mode 100644 android/universal_apk.gitlab-ci.yml

diff --git a/android/universal_apk.gitlab-ci.yml b/android/universal_apk.gitlab-ci.yml
new file mode 100644
index 0000000..dc47520
--- /dev/null
+++ b/android/universal_apk.gitlab-ci.yml
@@ -0,0 +1,33 @@
+# Required variables:
+## SIGNING_KEYSTORE: The keystore, base64 encoded
+## SIGNING_STORE_PW: The password for the keystore, keyPassword property in the signing.properties file
+## SIGNING_KEY_PW: The password for the key, keyPassword property in the signing.properties file
+## SIGNING_KEY_ALIAS: The alias for the key, keyAlias property in the signing.properties file
+## APPLICATION_VERSION: The build name of the application
+## APPLICATION_BUILD_NUMBER: The build number of the application
+## AAB_NAME: Path to the built aab file
+## APK_NAME: The name of the output apk
+
+stages:
+- build
+
+variables:
+  BUNDLETOOL_IMAGE: andrijoos/bundletool
+  APK_NAME: ${APP_NAME}_${APPLICATION_VERSION}.apk
+
+.build_universal_apk:
+  stage: build
+  image: 
+    name: ${BUNDLETOOL_IMAGE}
+    pull_policy: always
+  tags:
+    - amd64
+  artifacts:
+    paths:
+      - ${APK_NAME}
+    expire_in: 1 day
+  script:
+    - echo $SIGNING_KEYSTORE | base64 -d > keystore.jks
+    - bundletool build-apks --bundle=${AAB_NAME} --output=apks.apks --mode=universal --ks=keystore.jks --ks-pass=pass:$SIGNING_STORE_PW --ks-key-alias=$SIGNING_KEY_ALIAS --key-pass=pass:$SIGNING_KEY_PW
+    - unzip -q apks.apks -d apks
+    - mv apks/universal.apk ./${APK_NAME}
diff --git a/flutter/flutter-android.gitlab-ci.yml b/flutter/flutter-android.gitlab-ci.yml
index 8f5dd11..7a673bf 100644
--- a/flutter/flutter-android.gitlab-ci.yml
+++ b/flutter/flutter-android.gitlab-ci.yml
@@ -5,7 +5,7 @@
 ## SIGNING_KEY_PW: The password for the key, keyPassword property in the signing.properties file
 ## SIGNING_KEY_ALIAS: The alias for the key, keyAlias property in the signing.properties file
 ## APP_DIRECTORY: The directory of the app
-## APP_NAME: The name of the output aab, the resulting apk will be named ${APP_NAME}_${APPLICATION_VERSION}.apk
+## AAB_NAME: The name of the output aab
 ## APPLICATION_VERSION: The build name of the application
 ## APPLICATION_BUILD_NUMBER: The build number of the application
 
@@ -16,10 +16,7 @@ variables:
   SIGNING_PROPERTIES_FILE: android/signing.properties
   SINGING_KEYSTORE_FILE: android/signing-keystore.jks
   FLUTTER_ANDROID_IMAGE: andrijoos/flutter:3.24.5-android
-  BUNDLETOOL_IMAGE: andrijoos/bundletool
   ANDROID_PLATFORMS: android-arm,android-arm64,android-x64
-  AAB_NAME: ${APP_NAME}_${APPLICATION_VERSION}.aab
-  APK_NAME: ${APP_NAME}_${APPLICATION_VERSION}.apk
 
 .build_android:
   stage: build
@@ -42,20 +39,3 @@ variables:
     - flutter build appbundle --release --target-platform ${ANDROID_PLATFORMS} --build-name ${APPLICATION_VERSION} --build-number ${APPLICATION_BUILD_NUMBER}
   after_script:
     - mv ${APP_DIRECTORY}/build/app/outputs/bundle/release/app-release.aab ./${AAB_NAME}
-
-.build_universal_apk:
-  stage: build
-  image: 
-    name: ${BUNDLETOOL_IMAGE}
-    pull_policy: always
-  tags:
-    - amd64
-  artifacts:
-    paths:
-      - ${APK_NAME}
-    expire_in: 1 day
-  script:
-    - echo $SIGNING_KEYSTORE | base64 -d > keystore.jks
-    - bundletool build-apks --bundle=${AAB_NAME} --output=apks.apks --mode=universal --ks=keystore.jks --ks-pass=pass:$SIGNING_STORE_PW --ks-key-alias=$SIGNING_KEY_ALIAS --key-pass=pass:$SIGNING_KEY_PW
-    - unzip -q apks.apks -d apks
-    - mv apks/universal.apk ./${APK_NAME}
-- 
GitLab