From abc18c14a40c0fb3512986ebfb5f9b19377fa4ac Mon Sep 17 00:00:00 2001 From: Christian Haser <32584944+CryZo@users.noreply.github.com> Date: Sun, 7 Apr 2024 12:38:52 +0200 Subject: [PATCH] Google Play deployment --- .github/workflows/android.yml | 2 +- app/build.gradle.kts | 19 +++++++++++++++++-- app/version.properties | 1 + fastlane/Fastfile | 5 +++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 app/version.properties diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d6d6931..5b4ca55 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -119,7 +119,7 @@ jobs: ${{ github.workspace }}/app/build/outputs/bundle/release - name: version - run: echo "CUR_VERSION=$(grep -o -E 'versionName = \"[[:digit:]\.]+\"' app/build.gradle.kts | grep -o -E '[[:digit:]\.]+')" >> $GITHUB_OUTPUT + run: source app/version.properties && echo "CUR_VERSION=$VERSION" >> $GITHUB_OUTPUT id: version - name: Release diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 77123cf..ca4dae3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,18 @@ +import java.util.Locale +import java.util.Properties + +fun buildVersionName(): String { + val props = Properties() + file("version.properties").inputStream().use { props.load(it) } + return props.getProperty("VERSION") +} + +val buildVersionCode: Int = run { + val versionName = buildVersionName() + val (major, minor, patch) = versionName.lowercase(Locale.getDefault()).split('.').map { it.toInt() } + (major * 10000) + (minor * 100) + patch +} + plugins { alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsKotlinAndroid) @@ -11,8 +26,8 @@ android { applicationId = "com.chaser.paintballnotificator" minSdk = 24 targetSdk = 34 - versionCode = 2 - versionName = "1.1.2" + versionCode = buildVersionCode + versionName = buildVersionName() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/app/version.properties b/app/version.properties new file mode 100644 index 0000000..8ce0be0 --- /dev/null +++ b/app/version.properties @@ -0,0 +1 @@ +VERSION=1.1.3 \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index e6d54a3..154097b 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -40,6 +40,11 @@ platform :android do desc "Deploy a new version to Google Play" lane :deploy do + properties = property_file_read(file: "android/version/version.properties") + version_name = properties["VERSION"] + major, minor, patch = version_name.downcase.split('.').map(&:to_i) + version_code = (major * 10_000) + (minor * 100) + patch + upload_to_play_store( track: "internal", json_key: ENV["ANDROID_JSON_KEY_FILE"]