android/makefile: add tv-specific build variant (#445)

android/makefile: add tv-specific build

 updates tailscale/corp#21644

This will build a second tailscale-release-tv.aab with the leanback flag set
suitable for submission for android-tv.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
pull/447/head
Jonathan Nobels 4 months ago committed by GitHub
parent c4a1dec8eb
commit 2f59feef20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

8
.gitignore vendored

@ -19,12 +19,8 @@ android/local.properties
.idea .idea
# Output files from the Makefile: # Output files from the Makefile:
tailscale-debug.apk *.apk
tailscale-release.aab *.aab
tailscale-fdroid.apk
tailscale-new-fdroid.apk
tailscale-new-debug.apk
tailscale-test.apk
# Signing key # Signing key
tailscale.jks tailscale.jks

@ -8,10 +8,11 @@
# The docker image to use for the build environment. Changing this # The docker image to use for the build environment. Changing this
# will force a rebuild of the docker image. If there is an existing image # will force a rebuild of the docker image. If there is an existing image
# with this name, it will be used. # with this name, it will be used.
DOCKER_IMAGE=tailscale-android-build-amd64-1 DOCKER_IMAGE=tailscale-android-build-amd64-2
DEBUG_APK=tailscale-debug.apk DEBUG_APK=tailscale-debug.apk
RELEASE_AAB=tailscale-release.aab RELEASE_AAB=tailscale-release.aab
RELEASE_TV_AAB=tailscale-tv-release.aab
LIBTAILSCALE=android/libs/libtailscale.aar LIBTAILSCALE=android/libs/libtailscale.aar
TAILSCALE_VERSION=$(shell ./version/tailscale-version.sh 200) TAILSCALE_VERSION=$(shell ./version/tailscale-version.sh 200)
OUR_VERSION=$(shell git describe --dirty --exclude "*" --always --abbrev=200) OUR_VERSION=$(shell git describe --dirty --exclude "*" --always --abbrev=200)
@ -88,10 +89,16 @@ apk: $(DEBUG_APK) ## Build the debug APK
.PHONY: tailscale-debug .PHONY: tailscale-debug
tailscale-debug: $(DEBUG_APK) ## Build the debug APK tailscale-debug: $(DEBUG_APK) ## Build the debug APK
# Builds the release AAB and signs it (phone/tablet/chromeOS variant)
.PHONY: release .PHONY: release
release: 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 @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: 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. # gradle-dependencies groups together the android sources and libtailscale needed to assemble tests/debug/release builds.
.PHONY: gradle-dependencies .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)
@ -104,6 +111,10 @@ $(RELEASE_AAB): gradle-dependencies
(cd android && ./gradlew test bundleRelease) (cd android && ./gradlew test bundleRelease)
install -C ./android/build/outputs/bundle/release/android-release.aab $@ install -C ./android/build/outputs/bundle/release/android-release.aab $@
$(RELEASE_TV_AAB): gradle-dependencies
(cd android && ./gradlew test bundleRelease_tv)
install -C ./android/build/outputs/bundle/release_tv/android-release_tv.aab $@
tailscale-test.apk: gradle-dependencies tailscale-test.apk: gradle-dependencies
(cd android && ./gradlew assembleApplicationTestAndroidTest) (cd android && ./gradlew assembleApplicationTestAndroidTest)
install -C ./android/build/outputs/apk/androidTest/applicationTest/android-applicationTest-androidTest.apk $@ install -C ./android/build/outputs/apk/androidTest/applicationTest/android-applicationTest-androidTest.apk $@
@ -166,9 +177,16 @@ androidpath:
@echo "export ANDROID_SDK_ROOT=$(ANDROID_SDK_ROOT)" @echo "export ANDROID_SDK_ROOT=$(ANDROID_SDK_ROOT)"
@echo 'export PATH=$(ANDROID_HOME)/cmdline-tools/latest/bin:$(ANDROID_HOME)/platform-tools:$$PATH' @echo 'export PATH=$(ANDROID_HOME)/cmdline-tools/latest/bin:$(ANDROID_HOME)/platform-tools:$$PATH'
.PHONY: tag_release .PHONY: bump_version_code
tag_release: ## Tag a release bump_version_code: ## Bump the version code in the android build.gradle
@echo "Current Version Code:"
@grep "versionCode" android/build.gradle
sed -i'.bak' 's/versionCode $(VERSIONCODE)/versionCode $(VERSIONCODE_PLUSONE)/' android/build.gradle && rm android/build.gradle.bak sed -i'.bak' 's/versionCode $(VERSIONCODE)/versionCode $(VERSIONCODE_PLUSONE)/' android/build.gradle && rm android/build.gradle.bak
@echo "New Version Code:"
@grep "versionCode" android/build.gradle
.PHONY: tag_release
tag_release: bump_version_code ## Increment the playstore version code by 1
sed -i'.bak' 's/versionName .*/versionName "$(VERSION_LONG)"/' android/build.gradle && rm android/build.gradle.bak sed -i'.bak' 's/versionName .*/versionName "$(VERSION_LONG)"/' android/build.gradle && rm android/build.gradle.bak
git commit -sm "android: bump version code" android/build.gradle git commit -sm "android: bump version code" android/build.gradle
git tag -a "$(VERSION_LONG)" git tag -a "$(VERSION_LONG)"
@ -249,7 +267,7 @@ docker-remove-shell-image: ## Removes all docker shell image
.PHONY: clean .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.
-rm -rf android/build $(DEBUG_APK) $(RELEASE_AAB) $(LIBTAILSCALE) android/libs *.apk *.aab -rm -rf android/build $(DEBUG_APK) $(RELEASE_AAB) $(RELEASE_TV_AAB) $(LIBTAILSCALE) android/libs *.apk *.aab
-pkill -f gradle -pkill -f gradle
.PHONY: help .PHONY: help

@ -65,11 +65,27 @@ android {
buildTypes { buildTypes {
applicationTest { applicationTest {
initWith debug initWith debug
manifestPlaceholders.leanbackRequired = false
buildConfigField "String", "GITHUB_USERNAME", "\"" + getLocalProperty("githubUsername")+"\"" buildConfigField "String", "GITHUB_USERNAME", "\"" + getLocalProperty("githubUsername")+"\""
buildConfigField "String", "GITHUB_PASSWORD", "\"" + getLocalProperty("githubPassword")+"\"" buildConfigField "String", "GITHUB_PASSWORD", "\"" + getLocalProperty("githubPassword")+"\""
buildConfigField "String", "GITHUB_2FA_SECRET", "\"" + getLocalProperty("github2FASecret")+"\"" buildConfigField "String", "GITHUB_2FA_SECRET", "\"" + getLocalProperty("github2FASecret")+"\""
} }
debug {
manifestPlaceholders.leanbackRequired = false
}
release { release {
manifestPlaceholders.leanbackRequired = false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
release_tv {
manifestPlaceholders.leanbackRequired = true
minifyEnabled true minifyEnabled true
shrinkResources true shrinkResources true

@ -24,7 +24,7 @@
<!-- Signal support for Android TV --> <!-- Signal support for Android TV -->
<uses-feature <uses-feature
android:name="android.software.leanback" android:name="android.software.leanback"
android:required="false" /> android:required="${leanbackRequired}" />
<uses-feature <uses-feature
android:name="android.hardware.touchscreen" android:name="android.hardware.touchscreen"
android:required="false" /> android:required="false" />

@ -44,4 +44,8 @@ RUN ./android/gradlew
# Build the android app # Build the android app
CMD make clean CMD make clean
CMD make release CMD make release
# Build the android tv app. We need to bump the version code by 1
# so the AAB is unique.
CMD make bump_version_code
CMD make release-tv

Loading…
Cancel
Save