diff --git a/.drone.yml b/.drone.yml index b616187..9d8243f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -118,6 +118,7 @@ steps: - dart run build_runner build - flutter build apk --release + --flavor publish --build-name $(git describe --tags --abbrev=0) --target-platform android-arm64 --build-number $(git rev-list --count $(git describe --tags --abbrev=0)) diff --git a/moneymgr_mobile/android/.gitignore b/moneymgr_mobile/android/.gitignore index be3943c..919323b 100644 --- a/moneymgr_mobile/android/.gitignore +++ b/moneymgr_mobile/android/.gitignore @@ -1,3 +1,5 @@ +publish_key.properties + gradle-wrapper.jar /.gradle /captures/ diff --git a/moneymgr_mobile/android/README.md b/moneymgr_mobile/android/README.md new file mode 100644 index 0000000..bd6e15d --- /dev/null +++ b/moneymgr_mobile/android/README.md @@ -0,0 +1,8 @@ +# Android version of application + +Generate keystore: + +```bash +keytool -genkey -v -keystore ./keystore.jks -keyalg RSA \ + -keysize 2048 -validity 20000 -alias moneymgr +``` diff --git a/moneymgr_mobile/android/app/build.gradle.kts b/moneymgr_mobile/android/app/build.gradle.kts index 25686ad..8aa7fb3 100644 --- a/moneymgr_mobile/android/app/build.gradle.kts +++ b/moneymgr_mobile/android/app/build.gradle.kts @@ -1,3 +1,6 @@ +import java.util.Properties +import java.io.FileInputStream + plugins { id("com.android.application") id("kotlin-android") @@ -5,6 +8,12 @@ plugins { id("dev.flutter.flutter-gradle-plugin") } +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("publish_key.properties") +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} + android { namespace = "org.communiquons.moneymgr" compileSdk = flutter.compileSdkVersion @@ -21,7 +30,6 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "org.communiquons.moneymgr" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. @@ -31,17 +39,33 @@ android { versionName = flutter.versionName } - buildTypes { - debug { - applicationIdSuffix = ".debug" + signingConfigs { + create("publish") { + keyAlias = keystoreProperties["keyAlias"] as String + keyPassword = keystoreProperties["keyPassword"] as String + storeFile = keystoreProperties["storeFile"]?.let { file(it) } + storePassword = keystoreProperties["storePassword"] as String } + } + buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. signingConfig = signingConfigs.getByName("debug") } } + + flavorDimensions += "default" + productFlavors { + create("development") { + dimension = "default" + applicationIdSuffix = ".debug" + } + create("publish") { + dimension = "default" + signingConfig = signingConfigs.getByName("publish") + } + } + } flutter { diff --git a/moneymgr_mobile/android/app/src/release/AndroidManifest.xml b/moneymgr_mobile/android/app/src/publish/AndroidManifest.xml similarity index 100% rename from moneymgr_mobile/android/app/src/release/AndroidManifest.xml rename to moneymgr_mobile/android/app/src/publish/AndroidManifest.xml diff --git a/moneymgr_mobile/android/app/src/release/res/xml/data_extraction_rules.xml b/moneymgr_mobile/android/app/src/publish/res/xml/data_extraction_rules.xml similarity index 100% rename from moneymgr_mobile/android/app/src/release/res/xml/data_extraction_rules.xml rename to moneymgr_mobile/android/app/src/publish/res/xml/data_extraction_rules.xml diff --git a/moneymgr_mobile/android/publish_key.sample b/moneymgr_mobile/android/publish_key.sample new file mode 100644 index 0000000..df1e259 --- /dev/null +++ b/moneymgr_mobile/android/publish_key.sample @@ -0,0 +1,4 @@ +storePassword= +keyPassword= +keyAlias=upload +storeFile= diff --git a/moneymgr_mobile/pubspec.yaml b/moneymgr_mobile/pubspec.yaml index c019987..100db0c 100644 --- a/moneymgr_mobile/pubspec.yaml +++ b/moneymgr_mobile/pubspec.yaml @@ -127,6 +127,9 @@ dev_dependencies: # The following section is specific to Flutter packages. flutter: + # Default Android flavor + default-flavor: development + # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class.