diff --git a/Makefile b/Makefile index e74abfa396..7cae31036f 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,7 @@ $(RELEASE_AAB): version gradle-dependencies $(RELEASE_TV_AAB): version gradle-dependencies @echo "Building TV release AAB" - (cd android && ./gradlew test bundleRelease_tv) + (cd android && ./gradlew test bundleTvRelease -PPLATFORM=1) install -C ./android/build/outputs/bundle/release_tv/android-release_tv.aab $@ tailscale-test.apk: version gradle-dependencies @@ -279,9 +279,12 @@ 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 the version code in build.gradle -bump_version_code: - 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 +## Set the version code for Android TV builds (platform=1) +.PHONY: set_version_code_tv +set_version_code_tv: tailscale.version + @source tailscale.version && \ + sed -i'.bak' "s/versionCode .*/versionCode $$(( VERSION_MAJOR * 100000000 + VERSION_MINOR * 100000 + VERSION_PATCH * 10 + 1 ))/" android/build.gradle && \ + rm android/build.gradle.bak .PHONY: update-oss ## Update the tailscale.com go module update-oss: diff --git a/android/build.gradle b/android/build.gradle index 7858fde628..0d5b093eda 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -37,7 +37,7 @@ android { defaultConfig { minSdkVersion 26 targetSdkVersion 35 - versionCode 615 + versionCode computeVersionCode() versionName getVersionProperty("VERSION_LONG") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -195,3 +195,15 @@ def getVersionProperty(key) { versionProps.load(project.file('../tailscale.version').newDataInputStream()) return versionProps.getProperty(key).replaceAll('^\"|\"$', '') } + +def computeVersionCode() { + def versionProps = new Properties() + versionProps.load(project.file('../tailscale.version').newDataInputStream()) + + def major = versionProps.getProperty('VERSION_MAJOR') as int + def minor = versionProps.getProperty('VERSION_MINOR') as int + def patch = versionProps.getProperty('VERSION_PATCH') as int + def platform = (project.findProperty('PLATFORM') ?: '0') as int + + return major * 100000000 + minor * 100000 + patch * 10 + platform +} \ No newline at end of file diff --git a/docker/DockerFile.amd64-build b/docker/DockerFile.amd64-build index a08af109b5..1ec0b86c26 100644 --- a/docker/DockerFile.amd64-build +++ b/docker/DockerFile.amd64-build @@ -43,4 +43,4 @@ RUN chmod 755 android/gradlew && \ ./android/gradlew # Build the android app, bump the playstore version code, and make the tv release -CMD make clean && make release && make bump_version_code && make release-tv +CMD make clean && make release && make release-tv