File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export GOPROXY
3939# Active module mode, as we use go modules to manage dependencies
4040export GO111MODULE =on
4141
42+ BRANCHVERSION := $(shell git symbolic-ref --short HEAD)
4243# Hosts running SELinux need :z added to volume mounts
4344SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
4445
@@ -174,7 +175,7 @@ release-binary: $(RELEASE_DIR)
174175 -v " $$ (pwd):/workspace$( DOCKER_VOL_OPTS) " \
175176 -w /workspace/tools/setup-envtest \
176177 golang:$(GO_VERSION ) \
177- go build -a -trimpath -ldflags " -extldflags '-static'" \
178+ go build -a -trimpath -ldflags " -X 'main.BranchVersion= $( BRANCHVERSION ) ' - extldflags '-static'" \
178179 -o ./out/$(RELEASE_BINARY ) ./
179180
180181# # --------------------------------------
Original file line number Diff line number Diff line change 5151 "directory to store binary assets (default: $OS_SPECIFIC_DATA_DIR/envtest-binaries)" )
5252
5353 index = flag .String ("index" , remote .DefaultIndexURL , "index to discover envtest binaries" )
54+
55+ BranchVersion = "unknown"
5456)
5557
5658// TODO(directxman12): handle interrupts?
@@ -256,7 +258,6 @@ Environment Variables:
256258 version = flag .Arg (1 )
257259 }
258260 env := setupEnv (globalLog , version )
259-
260261 // perform our main set of actions
261262 switch action := flag .Arg (0 ); action {
262263 case "use" :
@@ -274,6 +275,10 @@ Environment Variables:
274275 Input : os .Stdin ,
275276 PrintFormat : printFormat ,
276277 }.Do (env )
278+ case "version" :
279+ workflows.Version {
280+ BinaryVersion : BranchVersion ,
281+ }.Do (env )
277282 default :
278283 flag .Usage ()
279284 envp .Exit (2 , "unknown action %q" , action )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package workflows
55
66import (
77 "context"
8+ "fmt"
89 "io"
910
1011 "github.com/go-logr/logr"
@@ -85,3 +86,11 @@ func (f Sideload) Do(env *envp.Env) {
8586 env .Sideload (ctx , f .Input )
8687 env .PrintInfo (f .PrintFormat )
8788}
89+
90+ type Version struct {
91+ BinaryVersion string
92+ }
93+
94+ func (v Version ) Do (env * envp.Env ) {
95+ fmt .Fprintf (env .Out , "setup-envtest version: %s\n " , v .BinaryVersion )
96+ }
You can’t perform that action at this time.
0 commit comments