From 6b28e2deae1d66eb7f5d3a93f656dd28857e5857 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Wed, 7 Aug 2024 15:01:08 -0400 Subject: [PATCH] Make version auto-detectable using tags and detectable in Syft Signed-off-by: Laurent Goderre --- Makefile | 16 ++++++++-------- NOTARY_VERSION | 1 - client/client_test.go | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 NOTARY_VERSION diff --git a/Makefile b/Makefile index 170ca54bb..5c712fd4b 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ GOFLAGS := -mod=vendor # Populate version variables # Add to compile time flags NOTARY_PKG := github.com/theupdateframework/notary -NOTARY_VERSION := $(shell cat NOTARY_VERSION) +NOTARY_VERSION := $(shell git describe) GITCOMMIT := $(shell git rev-parse --short HEAD) GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no) ifneq ($(GITUNTRACKEDCHANGES),) GITCOMMIT := $(GITCOMMIT)-dirty endif -CTIMEVAR=-X $(NOTARY_PKG)/version.GitCommit=$(GITCOMMIT) -X $(NOTARY_PKG)/version.NotaryVersion=$(NOTARY_VERSION) +CTIMEVAR=-X $(NOTARY_PKG)/version.GitCommit=$(GITCOMMIT) -X $(NOTARY_PKG)/version.NotaryVersion=$(NOTARY_VERSION) -X $(NOTARY_PKG)/version.Version=$(NOTARY_VERSION) GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)" GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static" GOOSES = darwin linux windows @@ -45,19 +45,19 @@ all: clean lint build test binaries version/version.go: ./version/version.sh > $@ -${PREFIX}/bin/notary-server: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/notary-server: $(shell find . -type f -name '*.go') @echo "+ $@" @go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS} ./cmd/notary-server -${PREFIX}/bin/notary: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/notary: $(shell find . -type f -name '*.go') @echo "+ $@" @go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS} ./cmd/notary -${PREFIX}/bin/notary-signer: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/notary-signer: $(shell find . -type f -name '*.go') @echo "+ $@" @go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS} ./cmd/notary-signer -${PREFIX}/bin/escrow: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/escrow: $(shell find . -type f -name '*.go') @echo "+ $@" @go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS} ./cmd/escrow @@ -71,11 +71,11 @@ ${PREFIX}/bin/static/notary-signer: ${PREFIX}/bin/static/notary: @echo "notary: static builds not supported on OS X" else -${PREFIX}/bin/static/notary-server: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/static/notary-server: $(shell find . -type f -name '*.go') @echo "+ $@" @(export CGO_ENABLED=0; go build -tags "${NOTARY_BUILDTAGS} netgo" -o $@ ${GO_LDFLAGS_STATIC} ./cmd/notary-server) -${PREFIX}/bin/static/notary-signer: NOTARY_VERSION $(shell find . -type f -name '*.go') +${PREFIX}/bin/static/notary-signer: $(shell find . -type f -name '*.go') @echo "+ $@" @(export CGO_ENABLED=0; go build -tags "${NOTARY_BUILDTAGS} netgo" -o $@ ${GO_LDFLAGS_STATIC} ./cmd/notary-signer) diff --git a/NOTARY_VERSION b/NOTARY_VERSION deleted file mode 100644 index faef31a43..000000000 --- a/NOTARY_VERSION +++ /dev/null @@ -1 +0,0 @@ -0.7.0 diff --git a/client/client_test.go b/client/client_test.go index a233397a6..25b1ae30d 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -2592,7 +2592,7 @@ func TestPublishRemoveDelegationKeyFromDelegationRole(t *testing.T) { "", tdJSON, ))) - cl.Close() + _ = cl.Close() require.NoError(t, ownerRepo.Publish()) // delegated repo can now no longer publish to delegated role