Skip to content

Commit 1c2e9e4

Browse files
authored
refactor(build): remove dynamic version calculation from build script. #31 (#353)
Removed functions in build.gradle.kts that dynamically calculate versionCode and versionName. Set static values for versionCode and versionName directly. Updated release.yml to retrieve versionName from build.gradle.kts instead of gradle.properties. > GENERATE BY https://aicommit.app
1 parent 744f548 commit 1c2e9e4

3 files changed

Lines changed: 4 additions & 26 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ jobs:
101101
keyPassword: ${{ secrets.KEY_PASSWORD }}
102102
- name: Set version from properties
103103
run: |
104-
majorVersion=$(grep 'majorVersion=' gradle.properties | cut -d'=' -f2)
105-
minorVersion=$(grep 'minorVersion=' gradle.properties | cut -d'=' -f2)
106-
patchVersion=$(grep 'patchVersion=' gradle.properties | cut -d'=' -f2)
107-
version="${majorVersion}.${minorVersion}.${patchVersion}"
104+
version=$(grep 'versionName = ' app/build.gradle.kts | awk -F'"' '{print $2}')
108105
echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV"
109106
- name: Publish release.
110107
if: success()

app/build.gradle.kts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,15 @@ plugins {
99
id(libs.plugins.spotless.get().pluginId)
1010
}
1111

12-
/**
13-
* read version from gradle.properties
14-
*/
15-
val majorVersion by properties
16-
val minorVersion by properties
17-
val patchVersion by properties
18-
19-
fun getVersionCode(): Int {
20-
return (majorVersion as String).toInt() * 10000 + (minorVersion as String).toInt() * 100 + (patchVersion as String).toInt()
21-
}
22-
23-
fun getVersionName(): String {
24-
return "$majorVersion.$minorVersion.$patchVersion"
25-
}
26-
2712
android {
2813
compileSdk = (Apps.compileSdk)
2914
buildToolsVersion = (Apps.buildTools)
3015
defaultConfig {
3116
applicationId = "me.rosuh.easywatermark"
3217
minSdk = (Apps.minSdk)
3318
targetSdk = (Apps.targetSdk)
34-
versionCode = getVersionCode()
35-
versionName = getVersionName()
19+
versionCode = 20905
20+
versionName = "2.9.5"
3621
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3722
}
3823

gradle.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,4 @@ org.gradle.unsafe.configuration-cache=true
2727
android.defaults.buildfeatures.buildconfig=true
2828
android.nonTransitiveRClass=false
2929
android.nonFinalResIds=false
30-
#org.gradle.unsafe.configuration-cache=true
31-
32-
majorVersion=2
33-
minorVersion=9
34-
patchVersion=5
30+
#org.gradle.unsafe.configuration-cache=true

0 commit comments

Comments
 (0)