Skip to content

Commit

Permalink
Google Play deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZo committed Apr 7, 2024
1 parent ead1ccd commit abc18c1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION=1.1.3
5 changes: 5 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit abc18c1

Please sign in to comment.