From 97a826d118d2fdc20dc0fbd6a444f98d5442b81f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 11 Nov 2020 16:42:01 +0100 Subject: [PATCH] Makefile: extract version information from build.gradle The tag_release target already writes the version into build.gradle. Ensure the exact same version information is used for the Go build. As a bonus, the F-Droid builder no longer needs a modern git installed for determining the version string. Signed-off-by: Elias Naur --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9363869..4ea30b9 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,14 @@ AAR=android/libs/ipn.aar KEYSTORE=tailscale.jks KEYSTORE_ALIAS=tailscale TAILSCALE_VERSION=$(shell ./version/tailscale-version.sh) -TAILSCALE_COMMIT=$(lastword $(subst -g, ,$(TAILSCALE_VERSION))) GIT_DESCRIBE=$(shell git describe --dirty --exclude "*" --always --abbrev=200) VERSION_LONG=$(shell ./version/mkversion.sh long $(TAILSCALE_VERSION) $(GIT_DESCRIBE)) -VERSION_SHORT=$(shell ./version/mkversion.sh short $(TAILSCALE_VERSION) $(GIT_DESCRIBE)) +# Extract the long version build.gradle's versionName and strip quotes. +VERSIONNAME=$(patsubst "%",%,$(lastword $(shell grep versionName android/build.gradle))) +# Extract the x.y.z part for the short version. +VERSIONNAME_SHORT=$(shell echo $(VERSIONNAME) | cut -d - -f 1) +TAILSCALE_COMMIT=$(shell echo $(VERSIONNAME) | cut -d - -f 2 | cut -d t -f 2) +# Extract the version code from build.gradle. VERSIONCODE=$(lastword $(shell grep versionCode android/build.gradle)) VERSIONCODE_PLUSONE=$(shell expr $(VERSIONCODE) + 1) @@ -30,10 +34,10 @@ $(DEBUG_APK): (cd android && ./gradlew assemblePlayDebug) mv android/build/outputs/apk/play/debug/android-play-debug.apk $@ -# This target is also used by the F-Droid metadata. +# This target is also used by the F-Droid builder. release_aar: mkdir -p android/libs - go run gioui.org/cmd/gogio -ldflags "-X tailscale.com/version.Long=$(VERSION_LONG) -X tailscale.com/version.Short=$(VERSION_SHORT) -X tailscale.com/version.GitCommit=$(TAILSCALE_COMMIT)" -tags xversion -buildmode archive -target android -appid $(APPID) -o $(AAR) github.com/tailscale/tailscale-android/cmd/tailscale + go run gioui.org/cmd/gogio -ldflags "-X tailscale.com/version.Long=$(VERSIONNAME) -X tailscale.com/version.Short=$(VERSIONNAME_SHORT) -X tailscale.com/version.GitCommit=$(TAILSCALE_COMMIT)" -tags xversion -buildmode archive -target android -appid $(APPID) -o $(AAR) github.com/tailscale/tailscale-android/cmd/tailscale $(RELEASE_AAB): release_aar (cd android && ./gradlew bundlePlayRelease)