From 34c58ab1e73dca9174a1fe2123f1b0a322f2d329 Mon Sep 17 00:00:00 2001 From: William Petit Date: Fri, 26 Apr 2024 15:28:24 +0200 Subject: [PATCH] ci: fix android build --- Jenkinsfile | 4 ++-- Makefile | 8 +++++--- android/app/build.gradle | 8 +++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0d4cf42..7587671 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ standardMakePipeline([ # Install utilities RUN apt-get update -y \ - && apt-get install -y wget curl tar build-essential ca-certificates git openjdk-17-jdk unzip locales jq moreutils + && apt-get install -y wget git curl tar build-essential ca-certificates git openjdk-17-jdk unzip locales jq moreutils # Set locale RUN locale-gen en_US.UTF-8 @@ -51,7 +51,7 @@ standardMakePipeline([ 'extras;google;google_play_services' ''', 'hooks': [ - 'pre-release': { + 'pre-build': { sh ''' make .mktools ''' diff --git a/Makefile b/Makefile index 7bdad1a..427b96d 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,8 @@ ANDROID_KEYSTORE_KEY_VALIDITY ?= 365000 ANDROID_BUILD_TOOLS_VERSION ?= 34.0.0 +VERSION_CODE ?= $(shell git rev-list master --first-parent --count) + APPS := main watch: tools/modd/bin/modd deps ## Watching updated files - live reload @@ -48,10 +50,10 @@ build-client: deps ## Build executable -o ./bin/client \ ./cmd/client -build-android: tools/gogio/bin/gogio deps ## Build executable +build-android: .mktools tools/gogio/bin/gogio deps ## Build executable mkdir -p dist CGO_ENABLED=1 GOOS=android CGO_CFLAGS="-I${JDK_PATH}/include -I${JDK_PATH}/include/linux -w" tools/gogio/bin/gogio -target android -buildmode archive -o android/app/libs/mobile.aar -x ./cmd/mobile - ( cd android && VERSION_NAME=$(MKT_PROJECT_VERSION)-debug ./gradlew assembleDebug ) + ( cd android && VERSION_CODE=$(VERSION_CODE) VERSION_NAME=$(MKT_PROJECT_VERSION)-debug ./gradlew assembleDebug ) $(ANDROID_KEYSTORE_FILE): keytool -genkey -noprompt \ @@ -65,7 +67,7 @@ $(ANDROID_KEYSTORE_FILE): release-android: $(ANDROID_KEYSTORE_FILE) tools/gogio/bin/gogio deps ## Build executable mkdir -p dist CGO_ENABLED=1 GOOS=android CGO_CFLAGS="-I${JDK_PATH}/include -I${JDK_PATH}/include/linux -w" tools/gogio/bin/gogio -target android -buildmode archive -o android/app/libs/mobile.aar -x ./cmd/mobile - ( cd android && VERSION_NAME=$(MKT_PROJECT_VERSION) ./gradlew assemble ) + ( cd android && VERSION_CODE=$(VERSION_CODE) VERSION_NAME=$(MKT_PROJECT_VERSION) ./gradlew assemble ) rm -f android/app/build/outputs/apk/release/app-release-unsigned-aligned.apk "$(ANDROID_HOME)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/zipalign" -p 4 android/app/build/outputs/apk/release/app-release-unsigned.apk android/app/build/outputs/apk/release/app-release-unsigned-aligned.apk "$(ANDROID_HOME)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/apksigner" \ diff --git a/android/app/build.gradle b/android/app/build.gradle index 7cd3f07..ba80947 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -3,10 +3,8 @@ plugins { id 'org.jetbrains.kotlin.android' } -def gitVersion() { - def counter = 0 - def process = "git rev-list master --first-parent --count".execute() - return process.text.toInteger() +def versionCode() { + return System.env.VERSION_CODE ? System.env.VERSION_CODE.toInteger() : 0 } def versionName() { @@ -21,7 +19,7 @@ android { applicationId "com.cadoles.arcast_player" minSdk 24 targetSdk 34 - versionCode gitVersion() + versionCode versionCode() versionName versionName() testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"