From d7dc087953ab7c67a1be08739465273b15973baf Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 16 Sep 2022 13:28:03 -0700 Subject: [PATCH] Add commit ReleaseVersion to routing to return to clients in version request Signed-off-by: Brian Meek --- .github/workflows/docker.yml | 2 ++ build/docker/Dockerfile.monolith | 4 +++- clientapi/routing/routing.go | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 642587924..4c1681bf2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -72,6 +72,8 @@ jobs: file: ./build/docker/Dockerfile.monolith platforms: ${{ env.PLATFORMS }} push: true + build-args: | + RELEASE_VERSION=${{ env.RELEASE_VERSION }} tags: | ${{ env.DOCKER_NAMESPACE }}/dendrite-monolith:latest ${{ env.DOCKER_NAMESPACE }}/dendrite-monolith:${{ env.RELEASE_VERSION }} diff --git a/build/docker/Dockerfile.monolith b/build/docker/Dockerfile.monolith index 3180e9626..2d75c8ac1 100644 --- a/build/docker/Dockerfile.monolith +++ b/build/docker/Dockerfile.monolith @@ -2,12 +2,14 @@ FROM docker.io/golang:1.19-alpine AS base RUN apk --update --no-cache add bash build-base +ARG RELEASE_VERSION="Unreleased" + WORKDIR /build COPY . /build RUN mkdir -p bin -RUN go build -trimpath -o bin/ ./cmd/dendrite-monolith-server +RUN go build -trimpath -o bin/ -ldflags="-X routing.ReleaseVersion=$RELEASE_VERSION" ./cmd/dendrite-monolith-server RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/generate-keys diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 81e16b1bc..de441b7d8 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -41,6 +41,8 @@ import ( "github.com/sirupsen/logrus" ) +var ReleaseVersion string + // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. // @@ -101,7 +103,7 @@ func Setup( JSON: struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` - BuildVersion string `json:"build_version"` + ReleaseVersion string `json:"release_version"` }{Versions: []string{ "r0.0.1", "r0.1.0", @@ -113,7 +115,7 @@ func Setup( "v1.0", "v1.1", "v1.2", - }, UnstableFeatures: unstableFeatures, BuildVersion: "TODO"}, + }, UnstableFeatures: unstableFeatures, ReleaseVersion: ReleaseVersion}, } }), ).Methods(http.MethodGet, http.MethodOptions)