From 9c4fbeabefd1eb78021c1fab794c312e8b41f4a2 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 3 Nov 2021 01:58:04 -0400 Subject: [PATCH 1/2] docker: include git hash in docker-built binary --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2ecffb1f..dd1afd19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ## build ergo binary FROM golang:1.17-alpine3.13 AS build-env -RUN apk add -U --force-refresh --no-cache --purge --clean-protected -l -u make +RUN apk add -U --force-refresh --no-cache --purge --clean-protected -l -u make git # copy ergo source WORKDIR /go/src/github.com/ergochat/ergo From f9ca172ad71b58a289f432123fd0ce0958cc789d Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 3 Nov 2021 02:15:46 -0400 Subject: [PATCH 2/2] include git tag in binary when available --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0ecc5622..18d39f20 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,17 @@ .PHONY: all install build release capdefs test smoke gofmt irctest GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null) +GIT_TAG := $(shell git tag --points-at HEAD 2> /dev/null | head -n 1) capdef_file = ./irc/caps/defs.go all: install install: - go install -v -ldflags "-X main.commit=$(GIT_COMMIT)" + go install -v -ldflags "-X main.commit=$(GIT_COMMIT) -X main.version=$(GIT_TAG)" build: - go build -v -ldflags "-X main.commit=$(GIT_COMMIT)" + go build -v -ldflags "-X main.commit=$(GIT_COMMIT) -X main.version=$(GIT_TAG)" release: goreleaser --skip-publish --rm-dist