Skip to content

Commit

Permalink
[SECURESIGN-1180] | Fixing Versioning (#150)
Browse files Browse the repository at this point in the history
* Fixing Versioning

* Git Hash and Build date to build
  • Loading branch information
tommyd450 authored Sep 12, 2024
1 parent 6ef9170 commit 292920e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Build.mak
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@

GIT_VERSION ?= $(shell git describe --tags --always --dirty)

GIT_HASH ?= $(shell git rev-parse HEAD)
DATE_FMT = +%Y-%m-%dT%H:%M:%SZ
SOURCE_DATE_EPOCH ?= $(shell git log -1 --no-show-signature --pretty=%ct)
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif
GIT_TREESTATE = "clean"
DIFF = $(shell git diff --quiet >/dev/null 2>&1; if [ $$? -eq 1 ]; then echo "1"; fi)
ifeq ($(DIFF), 1)
GIT_TREESTATE = "dirty"
endif

LDFLAGS=-buildid= -X github.com/sigstore/gitsign/pkg/version.gitVersion=$(GIT_VERSION)

.PHONY:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.gitsign.rh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY . .
USER root
RUN git stash && \
export GIT_VERSION=$(git describe --tags --always --dirty) && \
export GIT_HASH=$(git rev-parse HEAD) && \
export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') && \
git stash pop && \
go mod download && \
make -f Build.mak cross-platform && \
Expand Down

0 comments on commit 292920e

Please sign in to comment.