File tree Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1414 name : Upload binaries to release
1515 runs-on : ubuntu-latest
1616 steps :
17+ - name : Set env
18+ run : echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
1719 - name : Check out code
1820 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
1921 - name : Calculate go version
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ 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)
4342# Hosts running SELinux need :z added to volume mounts
4443SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
4544
@@ -175,7 +174,7 @@ release-binary: $(RELEASE_DIR)
175174 -v " $$ (pwd):/workspace$( DOCKER_VOL_OPTS) " \
176175 -w /workspace/tools/setup-envtest \
177176 golang:$(GO_VERSION ) \
178- go build -a -trimpath -ldflags " -X 'main.BranchVersion=$( BRANCHVERSION ) ' -extldflags '-static'" \
177+ go build -a -trimpath -ldflags " -X 'main.BranchVersion=$( RELEASE_TAG ) ' -extldflags '-static'" \
179178 -o ./out/$(RELEASE_BINARY ) ./
180179
181180# # --------------------------------------
Original file line number Diff line number Diff line change 5353 index = flag .String ("index" , remote .DefaultIndexURL , "index to discover envtest binaries" )
5454
5555 // BranchVersion is the current setup-envtest branch that is used for the binary version of setup-envtest.
56- BranchVersion = "unknown "
56+ BranchVersion = ""
5757)
5858
5959// TODO(directxman12): handle interrupts?
Original file line number Diff line number Diff line change 77 "context"
88 "fmt"
99 "io"
10+ "runtime/debug"
1011
1112 "github.com/go-logr/logr"
1213
@@ -95,5 +96,15 @@ type Version struct {
9596
9697// Do executes the workflow.
9798func (v Version ) Do (env * envp.Env ) {
99+ if v .BinaryVersion == "" {
100+ info , ok := debug .ReadBuildInfo ()
101+ if ! ok || info == nil || info .Main .Version == "" {
102+ // binary has not been built with module support or doesn't contain a version.
103+ fmt .Fprintf (env .Out , "setup-envtest version: %s\n " , "(unknown)" )
104+ return
105+ }
106+ fmt .Fprintf (env .Out , "setup-envtest version: %s\n " , info .Main .Version )
107+ return
108+ }
98109 fmt .Fprintf (env .Out , "setup-envtest version: %s\n " , v .BinaryVersion )
99110}
You can’t perform that action at this time.
0 commit comments