Skip to content

Commit

Permalink
Fix CI output file path & map appid from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
MarmadileManteater committed Feb 3, 2024
1 parent 61627e6 commit 3434da7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildAndroid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: freetube-${{ steps.versionNumber.outputs.result }}-Android.apk
path: app/build/outputs/apk/debug/app-debug.apk
path: android/app/build/outputs/apk/debug/app-debug.apk
23 changes: 17 additions & 6 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import groovy.json.JsonSlurper

fun getVersionInfo(project: Project): Pair<String, Int>? {
class VersionInfo {
val appId: String
val version: String
val versionCode: Int
constructor(givenId: String, givenVersion: String, givenCode: Int) {
appId = givenId
version = givenVersion
versionCode = givenCode
}
}

fun getVersionInfo(project: Project): VersionInfo {
val json = JsonSlurper()
val packageJsonPath = project.file("../../package.json")

val packageJson = json.parse(packageJsonPath) as Map<String, Any>
val versionName = packageJson["version"] as String

val appName = "io.freetubeapp." + packageJson["name"]
val parts = versionName.split("-")
val numbers = parts[0].split(".")
val major = numbers[0].toInt()
Expand All @@ -21,7 +32,7 @@ fun getVersionInfo(project: Project): Pair<String, Int>? {

val versionCode = major * 10000000 + minor * 10000000 + patch * 1000 + build

return Pair(versionName, versionCode)
return VersionInfo(appName, versionName, versionCode)
}

val versionInfo = getVersionInfo(project)
Expand All @@ -38,11 +49,11 @@ android {
enable = true
}
defaultConfig {
applicationId = "io.freetubeapp.freetube.development"
applicationId = versionInfo.appId
minSdk = 24
targetSdk = 34
versionCode = versionInfo!!.second
versionName = versionInfo!!.first
versionCode = versionInfo.versionCode
versionName = versionInfo.version

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down

0 comments on commit 3434da7

Please sign in to comment.