-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makefile,*: use tailscale.com/cmd/mkversion #546
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,5 @@ tailscale.jks | |
libtailscale.aar | ||
libtailscale-sources.jar | ||
.DS_Store | ||
|
||
tailscale.version | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,13 @@ 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 $(wildcard .git/HEAD) | ||
$(shell ./tool/go run tailscale.com/cmd/mkversion > tailscale.version) | ||
|
||
Comment on lines
+131
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, so we're still doing the full git clone pain, just hidden behind this tool There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, at least we now are down to one implementation of that behavior though! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hah. lolsob. |
||
.PHONY: version | ||
version: tailscale.version ## print the current version information | ||
raggi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cat tailscale.version | ||
|
||
# | ||
# Go Builds: | ||
# | ||
|
@@ -154,10 +147,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 +195,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 +299,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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ android { | |
minSdkVersion 26 | ||
targetSdkVersion 34 | ||
versionCode 241 | ||
versionName "1.77.44-tc0a1ed86c-gcafb114ae0a" | ||
versionName getVersionProperty("VERSION_LONG") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooooh hell yeah |
||
|
||
// This setting, which defaults to 'true', will cause Tailscale to fall | ||
// back to the Google DNS servers if it cannot determine what the | ||
|
@@ -182,3 +182,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('^\"|\"$', '') | ||
} | ||
Comment on lines
+187
to
+194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. groovy! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were going to check this file in to the repo? Or did you not
git add
it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to, but as it contains the local git sha as well, that would get stale, so I wanted to reduce the possibility of the file not being updated and the stale version information being included.