diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ed29225 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,2 @@ +include: + - local: 'receivers/android/.gitlab-ci.yml' diff --git a/receivers/android/.gitlab-ci.yml b/receivers/android/.gitlab-ci.yml index 2120d78..7511d8e 100644 --- a/receivers/android/.gitlab-ci.yml +++ b/receivers/android/.gitlab-ci.yml @@ -1,13 +1,19 @@ stages: -- buildAndDeployApk + - buildAndDeployApk + +variables: + ANDROID_VERSION_NAME: + value: "" + description: "Enter the version name here (e.g. 1.0.1)." + ANDROID_VERSION_CODE: + value: "" + description: "Enter the version code here (e.g. 1)." buildAndDeployApk: stage: buildAndDeployApk script: - - ./gradlew --stacktrace assembleRelease + - if [ -z "$ANDROID_VERSION_NAME" ] || [ -z "$ANDROID_VERSION_CODE" ]; then echo "Version name or code not specified. Skipping build."; exit 0; fi + - ./receivers/android/gradlew --stacktrace assembleRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE - cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fcast-release.apk - - git describe --tags > /var/www/html/fcast-version.txt - only: - - tags - except: - - branches + - cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fastcast-release.apk + when: manual diff --git a/receivers/android/app/build.gradle b/receivers/android/app/build.gradle index 70531f0..7dffc41 100644 --- a/receivers/android/app/build.gradle +++ b/receivers/android/app/build.gradle @@ -2,16 +2,15 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.10' - id 'org.ajoberstar.grgit' version '1.7.2' } ext { - gitVersionName = grgit.describe() - gitVersionCode = gitVersionName != null && gitVersionName.isInteger() ? gitVersionName.toInteger() : 1 + currentVersionName = project.hasProperty('versionName') ? project.property('versionName') : '1.0.0' + currentVersionCode = project.hasProperty('versionCode') ? Integer.parseInt(project.property('versionCode')) : 1 } -println("Version Name: $gitVersionName") -println("Version Code: $gitVersionCode") +println("Version Name: $currentVersionName") +println("Version Code: $currentVersionCode") def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('/opt/key.properties') @@ -27,8 +26,8 @@ android { applicationId "com.futo.fcast.receiver" minSdk 24 targetSdk 33 - versionCode gitVersionCode - versionName gitVersionName + versionCode currentVersionCode + versionName currentVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }