Skip to content

Commit 582940f

Browse files
authored
android: derive versionCode from tailscale version (#807)
Previously, versionCode was only set by the Play Store builder and never committed back to the repo, so fdroid wouldn't detect updates. Now, we compute versionCode deterministically using the formula major*100M + minor*100K + patch*10 + platform, so that fdroid and Play Store builds always produce the same value. Updates tailscale/tailscale#18969 Signed-off-by: kari-ts <kari@tailscale.com>
1 parent d53001c commit 582940f

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ $(RELEASE_AAB): version gradle-dependencies
151151

152152
$(RELEASE_TV_AAB): version gradle-dependencies
153153
@echo "Building TV release AAB"
154-
(cd android && ./gradlew test bundleRelease_tv)
154+
(cd android && ./gradlew test bundleTvRelease -PPLATFORM=1)
155155
install -C ./android/build/outputs/bundle/release_tv/android-release_tv.aab $@
156156

157157
tailscale-test.apk: version gradle-dependencies
@@ -279,10 +279,6 @@ bumposs: update-oss tailscale.version
279279
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
280280
source tailscale.version && git tag -a "$${VERSION_LONG}" -m "OSS and Version updated to $${VERSION_LONG}"
281281

282-
.PHONY: bump_version_code ## Bump the version code in build.gradle
283-
bump_version_code:
284-
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
285-
286282
.PHONY: update-oss ## Update the tailscale.com go module
287283
update-oss:
288284
curl -f https://raw.githubusercontent.com/tailscale/tailscale/refs/heads/main/go.toolchain.rev > go.toolchain.rev.new

android/build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
defaultConfig {
3838
minSdkVersion 26
3939
targetSdkVersion 35
40-
versionCode 615
40+
versionCode computeVersionCode()
4141
versionName getVersionProperty("VERSION_LONG")
4242
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4343

@@ -195,3 +195,15 @@ def getVersionProperty(key) {
195195
versionProps.load(project.file('../tailscale.version').newDataInputStream())
196196
return versionProps.getProperty(key).replaceAll('^\"|\"$', '')
197197
}
198+
199+
def computeVersionCode() {
200+
def versionProps = new Properties()
201+
versionProps.load(project.file('../tailscale.version').newDataInputStream())
202+
203+
def major = versionProps.getProperty('VERSION_MAJOR') as int
204+
def minor = versionProps.getProperty('VERSION_MINOR') as int
205+
def patch = versionProps.getProperty('VERSION_PATCH') as int
206+
def platform = (project.findProperty('PLATFORM') ?: '0') as int
207+
208+
return major * 100000000 + minor * 100000 + patch * 10 + platform
209+
}

docker/DockerFile.amd64-build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ RUN chmod 755 android/gradlew && \
4343
./android/gradlew
4444

4545
# Build the android app, bump the playstore version code, and make the tv release
46-
CMD make clean && make release && make bump_version_code && make release-tv
46+
CMD make clean && make release && make release-tv

0 commit comments

Comments
 (0)