Skip to content

Commit 609f169

Browse files
authored
fix: stripped binary now includes version (#2147)
Stripping removed the symbol encoding the version. Now the stripped binary rewrites the version file before build.
1 parent 00f23cf commit 609f169

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gotrue-arm64
55
gotrue.exe
66
auth
77
auth-arm64
8+
auth-arm64-strip
89
auth.exe
910

1011
coverage.out

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
.PHONY: all build deps dev-deps image migrate test vet sec format unused
22
CHECK_FILES?=./...
33

4-
FLAGS=-ldflags "-X github.com/supabase/auth/internal/utilities.Version=`git describe --tags`" -buildvcs=false
54
ifdef RELEASE_VERSION
6-
FLAGS=-ldflags "-X github.com/supabase/auth/internal/utilities.Version=v$(RELEASE_VERSION)" -buildvcs=false
5+
VERSION=v$(RELEASE_VERSION)
6+
else
7+
VERSION=$(shell git describe --tags)
78
endif
89

10+
FLAGS=-ldflags "-X github.com/supabase/auth/internal/utilities.Version=$(VERSION)" -buildvcs=false
11+
912
ifneq ($(shell docker compose version 2>/dev/null),)
1013
DOCKER_COMPOSE=docker compose
1114
else
@@ -23,7 +26,10 @@ build: deps ## Build the binary.
2326
CGO_ENABLED=0 go build $(FLAGS)
2427
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(FLAGS) -o auth-arm64
2528

26-
build-strip: deps ## Build a stripped binary.
29+
build-strip: deps ## Build a stripped binary, for which the version file needs to be rewritten.
30+
echo "package utilities" > internal/utilities/version.go
31+
echo "const Version = \"$(VERSION)\"" >> internal/utilities/version.go
32+
2733
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
2834
$(FLAGS) -ldflags "-s -w" -o auth-arm64-strip
2935

0 commit comments

Comments
 (0)