build_dist.sh: use cmd/mkversion to get version data

Replaces the former shell goop, which was a shell reimplementation
of a subset of version/mkversion.

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/7315/head
David Anderson 2 years ago committed by Dave Anderson
parent 45d9784f9d
commit 149de5e6d6

@ -55,6 +55,7 @@ jobs:
GOARCH: ${{ matrix.goarch }} GOARCH: ${{ matrix.goarch }}
- name: build variant CLIs - name: build variant CLIs
run: | run: |
export TS_USE_TOOLCHAIN=1
./build_dist.sh --extra-small ./cmd/tailscaled ./build_dist.sh --extra-small ./cmd/tailscaled
./build_dist.sh --box ./cmd/tailscaled ./build_dist.sh --box ./cmd/tailscaled
./build_dist.sh --extra-small --box ./cmd/tailscaled ./build_dist.sh --extra-small --box ./cmd/tailscaled

@ -21,6 +21,7 @@ jobs:
# GOROOT is specified so that the Go/Wasm that is trigged by build-pk # GOROOT is specified so that the Go/Wasm that is trigged by build-pk
# also picks up our custom Go toolchain. # also picks up our custom Go toolchain.
run: | run: |
export TS_USE_TOOLCHAIN=1
./build_dist.sh tailscale.com/cmd/tsconnect ./build_dist.sh tailscale.com/cmd/tsconnect
GOROOT="${HOME}/.cache/tailscale-go" ./tsconnect build-pkg GOROOT="${HOME}/.cache/tailscale-go" ./tsconnect build-pkg

@ -11,42 +11,25 @@
set -eu set -eu
IFS=".$IFS" read -r major minor patch <VERSION.txt go="go"
git_hash=$(git rev-parse HEAD) if [ -n "${TS_USE_TOOLCHAIN:-}" ]; then
if ! git diff-index --quiet HEAD; then go="./tool/go"
git_hash="${git_hash}-dirty"
fi fi
base_hash=$(git rev-list --max-count=1 HEAD -- VERSION.txt)
change_count=$(git rev-list --count HEAD "^$base_hash")
short_hash=$(echo "$git_hash" | cut -c1-9)
if expr "$minor" : "[0-9]*[13579]$" >/dev/null; then eval `$go run ./cmd/mkversion`
patch="$change_count"
change_suffix=""
elif [ "$change_count" != "0" ]; then
change_suffix="-$change_count"
else
change_suffix=""
fi
long_suffix="$change_suffix-t$short_hash"
MINOR="$major.$minor"
SHORT="$MINOR.$patch"
LONG="${SHORT}$long_suffix"
GIT_HASH="$git_hash"
if [ "$1" = "shellvars" ]; then if [ "$1" = "shellvars" ]; then
cat <<EOF cat <<EOF
VERSION_MINOR="$MINOR" VERSION_MINOR="$VERSION_MINOR"
VERSION_SHORT="$SHORT" VERSION_SHORT="$VERSION_SHORT"
VERSION_LONG="$LONG" VERSION_LONG="$VERSION_LONG"
VERSION_GIT_HASH="$GIT_HASH" VERSION_GIT_HASH="$VERSION_GIT_HASH"
EOF EOF
exit 0 exit 0
fi fi
tags="" tags=""
ldflags="-X tailscale.com/version.longStamp=${LONG} -X tailscale.com/version.shortStamp=${SHORT}" ldflags="-X tailscale.com/version.longStamp=${VERSION_LONG} -X tailscale.com/version.shortStamp=${VERSION_SHORT}"
# build_dist.sh arguments must precede go build arguments. # build_dist.sh arguments must precede go build arguments.
while [ "$#" -gt 1 ]; do while [ "$#" -gt 1 ]; do

Loading…
Cancel
Save