diff --git a/.gitignore b/.gitignore index aab96166e7..dd0dde50a8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ tailscale.jks libtailscale.aar libtailscale-sources.jar .DS_Store + +tailscale.version diff --git a/Makefile b/Makefile index 554d6d33b8..4bec4ccf1b 100644 --- a/Makefile +++ b/Makefile @@ -17,21 +17,7 @@ DEBUG_APK=tailscale-debug.apk RELEASE_AAB=tailscale-release.aab RELEASE_TV_AAB=tailscale-tv-release.aab LIBTAILSCALE=android/libs/libtailscale.aar -TAILSCALE_VERSION=$(shell ./version/tailscale-version.sh 200) -OUR_VERSION=$(shell git describe --dirty --exclude "*" --always --abbrev=200) -TAILSCALE_VERSION_ABBREV=$(shell ./version/tailscale-version.sh 11) -OUR_VERSION_ABBREV=$(shell git describe --exclude "*" --always --abbrev=11) -VERSION_LONG=$(TAILSCALE_VERSION_ABBREV)-g$(OUR_VERSION_ABBREV) -# 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 $(TAILSCALE_VERSION) | 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) -VERSION_LDFLAGS=-X tailscale.com/version.longStamp=$(VERSIONNAME) -X tailscale.com/version.shortStamp=$(VERSIONNAME_SHORT) -X tailscale.com/version.gitCommitStamp=$(TAILSCALE_COMMIT) -X tailscale.com/version.extraGitCommitStamp=$(OUR_VERSION) -FULL_LDFLAGS=$(VERSION_LDFLAGS) -w ifeq ($(shell uname),Linux) ANDROID_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip" ANDROID_TOOLS_SUM="bd1aa17c7ef10066949c88dc6c9c8d536be27f992a1f3b5a584f9bd2ba5646a0 commandlinetools-linux-9477386_latest.zip" @@ -111,17 +97,17 @@ tailscale-debug: $(DEBUG_APK) ## Build the debug APK # Builds the release AAB and signs it (phone/tablet/chromeOS variant) .PHONY: release -release: update-version jarsign-env $(RELEASE_AAB) ## Build the release AAB +release: jarsign-env $(RELEASE_AAB) ## Build the release AAB @jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore $(JKS_PATH) -storepass $(JKS_PASSWORD) $(RELEASE_AAB) tailscale # Builds the release AAB and signs it (androidTV variant) .PHONY: release-tv -release-tv: update-version jarsign-env $(RELEASE_TV_AAB) ## Build the release AAB +release-tv: jarsign-env $(RELEASE_TV_AAB) ## Build the release AAB @jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore $(JKS_PATH) -storepass $(JKS_PASSWORD) $(RELEASE_TV_AAB) tailscale # gradle-dependencies groups together the android sources and libtailscale needed to assemble tests/debug/release builds. .PHONY: gradle-dependencies -gradle-dependencies: $(shell find android -type f -not -path "android/build/*" -not -path '*/.*') $(LIBTAILSCALE) +gradle-dependencies: $(shell find android -type f -not -path "android/build/*" -not -path '*/.*') $(LIBTAILSCALE) tailscale.version $(DEBUG_APK): gradle-dependencies (cd android && ./gradlew test assembleDebug) @@ -141,6 +127,12 @@ tailscale-test.apk: gradle-dependencies (cd android && ./gradlew assembleApplicationTestAndroidTest) install -C ./android/build/outputs/apk/androidTest/applicationTest/android-applicationTest-androidTest.apk $@ +tailscale.version: go.mod go.sum .git/HEAD + $(shell ./tool/go run tailscale.com/cmd/mkversion > tailscale.version) + +version: tailscale.version ## print the current version information + cat tailscale.version + # # Go Builds: # @@ -154,10 +146,10 @@ $(GOBIN)/gomobile: $(GOBIN)/gobind go.mod go.sum $(GOBIN)/gobind: go.mod go.sum ./tool/go install golang.org/x/mobile/cmd/gobind -$(LIBTAILSCALE): Makefile android/libs $(shell find libtailscale -name *.go) go.mod go.sum $(GOBIN)/gomobile +$(LIBTAILSCALE): Makefile android/libs $(shell find libtailscale -name *.go) go.mod go.sum $(GOBIN)/gomobile tailscale.version $(GOBIN)/gomobile bind -target android -androidapi 26 \ -tags "$$(./build-tags.sh)" \ - -ldflags "$(FULL_LDFLAGS)" \ + -ldflags "-w $$(./version-ldflags.sh)" \ -o $@ ./libtailscale .PHONY: libtailscale @@ -202,29 +194,25 @@ androidpath: @echo 'export PATH=$(ANDROID_HOME)/cmdline-tools/latest/bin:$(ANDROID_HOME)/platform-tools:$$PATH' .PHONY: tag_release -tag_release: ## Tag the current commit with the current version - git tag -a "$(VERSION_LONG)" -m "OSS and Version updated to ${VERSION_LONG}" +tag_release: tailscale.version ## Tag the current commit with the current version + source tailscale.version && git tag -a "$${VERSION_LONG}" -m "OSS and Version updated to $${VERSION_LONG}" .PHONY: bumposs ## Bump to the latest oss and update the versions. -bumposs: update-oss update-version - git commit -sm "android: bump OSS" -m "OSS and Version updated to ${VERSION_LONG}" go.toolchain.rev android/build.gradle go.mod go.sum - git tag -a "$(VERSION_LONG)" -m "OSS and Version updated to ${VERSION_LONG}" +bumposs: update-oss tailscale.version + source tailscale.version && git commit -sm "android: bump OSS" -m "OSS and Version updated to $${VERSION_LONG}" go.toolchain.rev android/build.gradle go.mod go.sum + source tailscale.version && git tag -a "$${VERSION_LONG}" -m "OSS and Version updated to $${VERSION_LONG}" .PHONY: bump_version_code bump_version_code: ## Bump the version code in build.gradle - sed -i'.bak' 's/versionCode .*/versionCode $(VERSIONCODE_PLUSONE)/' android/build.gradle && rm android/build.gradle.bak - -.PHONY: update-version -update-version: ## Update the version in build.gradle - sed -i'.bak' 's/versionName .*/versionName "$(VERSION_LONG)"/' android/build.gradle && rm android/build.gradle.bak + sed -i'.bak' "s/versionCode .*/versionCode $$(expr $$(awk '/versionCode ([0-9]+)/{print $$2}' android/build.gradle) + 1)/" android/build.gradle && rm android/build.gradle.bak .PHONY: update-oss -update-oss: ## Update the tailscale.com go module and update the version in build.gradle +update-oss: ## Update the tailscale.com go module GOPROXY=direct ./tool/go get tailscale.com@main + ./tool/go mod tidy -compat=1.23 ./tool/go run tailscale.com/cmd/printdep --go > go.toolchain.rev.new mv go.toolchain.rev.new go.toolchain.rev - ./tool/go mod tidy -compat=1.23 # Get the commandline tools package, this provides (among other things) the sdkmanager binary. $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager: @@ -310,13 +298,13 @@ docker-remove-shell-image: ## Removes all docker shell image docker rmi --force tailscale-android-shell-amd64 .PHONY: clean -clean: ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that. -clean: ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that. +clean: clean-tailscale.version ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that. @echo "Cleaning up old build artifacts" -rm -rf android/build $(DEBUG_APK) $(RELEASE_AAB) $(RELEASE_TV_AAB) $(LIBTAILSCALE) android/libs *.apk *.aab @echo "Cleaning cached toolchain" -rm -rf $(HOME)/.cache/tailscale-go{,.extracted} -pkill -f gradle + -rm tailscale.version .PHONY: help help: ## Show this help diff --git a/android/build.gradle b/android/build.gradle index d2b1ad6989..a0055b929e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -38,7 +38,7 @@ android { minSdkVersion 26 targetSdkVersion 34 versionCode 241 - versionName "1.77.12-ta8f9c0d6e-g753b8d3fb4b" + versionName getVersionProperty("VERSION_LONG") // This setting, which defaults to 'true', will cause Tailscale to fall // back to the Google DNS servers if it cannot determine what the @@ -181,3 +181,13 @@ def getLocalProperty(key, defaultValue) { return defaultValue } } + + +def getVersionProperty(key) { + // tailscale.version is created / updated by the makefile, it is in a loosely + // Makfile/envfile format, which is also loosely a properties file format. + // make tailscale.version + def versionProps = new Properties() + versionProps.load(project.file('../tailscale.version').newDataInputStream()) + return versionProps.getProperty(key).replaceAll('^\"|\"$', '') +} diff --git a/go.mod b/go.mod index 9c44a3b628..7b93ba8a8f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/tailscale/wireguard-go v0.0.0-20240905161824-799c1978fafc golang.org/x/mobile v0.0.0-20240806205939-81131f6468ab inet.af/netaddr v0.0.0-20220617031823-097006376321 - tailscale.com v1.75.0-pre.0.20241014151013-a8f9c0d6e40a + tailscale.com v1.75.0-pre.0.20241018175349-bb60da276468 ) require ( diff --git a/go.sum b/go.sum index f674216543..e32cbd8bce 100644 --- a/go.sum +++ b/go.sum @@ -256,5 +256,5 @@ inet.af/netaddr v0.0.0-20220617031823-097006376321 h1:B4dC8ySKTQXasnjDTMsoCMf1sQ inet.af/netaddr v0.0.0-20220617031823-097006376321/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k= software.sslmate.com/src/go-pkcs12 v0.4.0 h1:H2g08FrTvSFKUj+D309j1DPfk5APnIdAQAB8aEykJ5k= software.sslmate.com/src/go-pkcs12 v0.4.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI= -tailscale.com v1.75.0-pre.0.20241014151013-a8f9c0d6e40a h1:nGLKfmPOA8dmMqGUjBDIaUD4RkXo+QpP3TXoAKVwvHU= -tailscale.com v1.75.0-pre.0.20241014151013-a8f9c0d6e40a/go.mod h1:myCwmhYBvMCF/5OgBYuIW42zscuEo30bAml7wABVZLk= +tailscale.com v1.75.0-pre.0.20241018175349-bb60da276468 h1:/gmZCsZi5IDP7TsYBfoLdl2/iomYzXoDcj+16/TuBgA= +tailscale.com v1.75.0-pre.0.20241018175349-bb60da276468/go.mod h1:myCwmhYBvMCF/5OgBYuIW42zscuEo30bAml7wABVZLk= diff --git a/version-ldflags.sh b/version-ldflags.sh new file mode 100755 index 0000000000..56f006a4c0 --- /dev/null +++ b/version-ldflags.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +source tailscale.version || echo >&2 "no tailscale.version file found" +if [[ -z "${VERSION_LONG}" ]]; then + exit 1 +fi +echo "-X tailscale.com/version.longStamp=${VERSION_LONG}" +echo "-X tailscale.com/version.shortStamp=${VERSION_SHORT}" +echo "-X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" +echo "-X tailscale.com/version.extraGitCommitStamp=${VERSION_EXTRA_HASH}" diff --git a/version/tailscale-version.sh b/version/tailscale-version.sh deleted file mode 100755 index adc01dc7b4..0000000000 --- a/version/tailscale-version.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# Print the version tailscale repository corresponding -# to the version listed in go.mod. - -set -euo pipefail - -# use the go toolchain from the tailscale.com -export TS_USE_TOOLCHAIN=1 - -go_list=$(go list -m tailscale.com) -# go list outputs `tailscale.com `. Extract the version. -mod_version=${go_list#tailscale.com} - -if [ -z "$mod_version" ]; then - echo >&2 "no version reported by go list -m tailscale.com: $go_list" - exit 1 -fi - -case "$mod_version" in - *-*-*) - # A pseudo-version such as "v1.1.1-0.20201030135043-eab6e9ea4e45" - # includes the commit hash. - mod_version=${mod_version##*-*-} - ;; -esac - -tailscale_clone=$(mktemp -d -t tailscale-clone-XXXXXXXXXX) -git clone -q https://github.com/tailscale/tailscale.git "$tailscale_clone" - -cd $tailscale_clone -git reset --hard -q -git clean -d -x -f -git fetch -q --all --tags -git checkout -q ${mod_version} - -eval $(./build_dist.sh shellvars) -git_hash=$(git rev-parse HEAD) -short_hash=$(echo "$git_hash" | cut -c1-9) -echo ${VERSION_SHORT}-t${short_hash} -cd /tmp -rm -rf "$tailscale_clone"