From 5ca8e5d66fd1c8a7c90318b7e6d0ac213a5a95a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Naveiras?= Date: Mon, 19 Jun 2023 18:08:15 +0100 Subject: [PATCH 1/2] Update Theatre go ldflags It seems that we created v3, these settings aren't working. It's very clear since the last release that I added a metric that shows this in Prometheus. This are the required changes to fix this: - In Dockefile, override two variables: VERSION and GIT_REVISION. The last one is a build argument that is injected on build time. - Fixed the path in the go package by adding the version, and update these references in goreleaser and the Makefile --- .goreleaser.yaml | 6 +++--- Dockerfile | 6 +++++- Makefile | 7 +++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 847a12e8..76f2b8ee 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,9 +19,9 @@ builds: - goos: linux goarch: arm64 ldflags: > - -X github.com/gocardless/theatre/cmd.Version={{.Version}} - -X github.com/gocardless/theatre/cmd.Commit={{.Commit}} - -X github.com/gocardless/theatre/cmd.Date={{.Date}} + -X github.com/gocardless/theatre/v3/cmd.Version={{.Version}} + -X github.com/gocardless/theatre/v3/cmd.Commit={{.Commit}} + -X github.com/gocardless/theatre/v3/cmd.Date={{.Date}} -a -installsuffix cgo env: diff --git a/Dockerfile b/Dockerfile index 11051acb..677931fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,10 @@ FROM golang:1.20.5 as builder WORKDIR /go/src/github.com/gocardless/theatre COPY . /go/src/github.com/gocardless/theatre +ARG git_revision=unset +RUN echo $git_revision > REVISION RUN set -x \ - && make VERSION="$(cat VERSION)" build + && make VERSION="$(cat VERSION)" GIT_REVISION="$(cat REVISION)" build # Use ubuntu as our base package to enable generic system tools FROM ubuntu:jammy-20230522 @@ -20,4 +22,6 @@ RUN set -x \ WORKDIR / COPY --from=builder /go/src/github.com/gocardless/theatre/bin/* /usr/local/bin/ +ARG git_revision=unset +RUN echo $git_revision > REVISION ENTRYPOINT ["/bin/bash"] diff --git a/Makefile b/Makefile index 87f5adde..ba60fa8e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ PROG=bin/rbac-manager bin/vault-manager bin/theatre-secrets bin/workloads-manager bin/theatre-consoles PROJECT=github.com/gocardless/theatre IMAGE=eu.gcr.io/gc-containers/gocardless/theatre -VERSION=$(shell git rev-parse --short HEAD)-dev -BUILD_COMMAND=go build -ldflags "-s -w -X main.Version=$(VERSION)" +VERSION=$(shell git describe --tags --dirty --long) +GIT_REVISION=$(shell git rev-parse HEAD) +DATE=$(shell date +"%Y%m%d.%H%M%S") +LDFLAGS=-ldflags "-s -X github.com/gocardless/theatre/v3/cmd.Version=$(VERSION) -X github.com/gocardless/theatre/v3/cmd.Commit=$(GIT_REVISION) -X github.com/gocardless/theatre/v3/cmd.Date=$(DATE)" +BUILD_COMMAND=go build $(LDFLAGS) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) From 94cb6db4e07b0fd74ec7a834c3decae52cd5220e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Naveiras?= Date: Mon, 19 Jun 2023 18:12:13 +0100 Subject: [PATCH 2/2] Bump a minor version 4.2.1 I consider this a bugfix, so it should be fine just increment the patch level, as it's backward. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6aba2b24..fae6e3d0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.0 +4.2.1