From 18dcc49ff4ac26f39f3ad54012f44c327eed345f Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sat, 1 Jan 2022 14:53:18 +0100 Subject: [PATCH] set version during build process see #47 --- .github/workflows/release-dev-version.yml | 2 +- .github/workflows/release-productive-version.yml | 2 +- Dockerfile | 6 ++++++ src/client/client.go | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-dev-version.yml b/.github/workflows/release-dev-version.yml index f2abf45..af008b7 100644 --- a/.github/workflows/release-dev-version.yml +++ b/.github/workflows/release-dev-version.yml @@ -38,4 +38,4 @@ jobs: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker buildx create --name multibuilder docker buildx use multibuilder - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION}-dev -t bbernhard/signal-cli-rest-api:latest-dev . --push + docker buildx build --build-arg BUILD_VERSION_ARG=${VERSION} --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION}-dev -t bbernhard/signal-cli-rest-api:latest-dev . --push diff --git a/.github/workflows/release-productive-version.yml b/.github/workflows/release-productive-version.yml index 8e6297d..88225b0 100644 --- a/.github/workflows/release-productive-version.yml +++ b/.github/workflows/release-productive-version.yml @@ -38,4 +38,4 @@ jobs: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker buildx create --name multibuilder docker buildx use multibuilder - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION} -t bbernhard/signal-cli-rest-api:latest . --push + docker buildx build --build-arg BUILD_VERSION_ARG=${VERSION} --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION} -t bbernhard/signal-cli-rest-api:latest . --push diff --git a/Dockerfile b/Dockerfile index aa04a87..89f3e92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ ARG SWAG_VERSION=1.6.7 ARG GRAALVM_JAVA_VERSION=17 ARG GRAALVM_VERSION=21.3.0 +ARG BUILD_VERSION_ARG=unset + FROM golang:1.17-bullseye AS buildcontainer ARG SIGNAL_CLI_VERSION @@ -12,6 +14,7 @@ ARG LIBSIGNAL_CLIENT_VERSION ARG SWAG_VERSION ARG GRAALVM_JAVA_VERSION ARG GRAALVM_VERSION +ARG BUILD_VERSION_ARG COPY ext/libraries/libsignal-client/v${LIBSIGNAL_CLIENT_VERSION} /tmp/libsignal-client-libraries @@ -117,6 +120,9 @@ ENV GIN_MODE=release ENV PORT=8080 ARG SIGNAL_CLI_VERSION +ARG BUILD_VERSION_ARG + +ENV BUILD_VERSION=$BUILD_VERSION_ARG RUN apt-get update \ && apt-get install -y --no-install-recommends util-linux supervisor netcat unzip \ diff --git a/src/client/client.go b/src/client/client.go index 4c5dc96..76bcdfe 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -119,6 +119,7 @@ type About struct { SupportedApiVersions []string `json:"versions"` BuildNr int `json:"build"` Mode string `json:"mode"` + Version string `json:"version"` } func cleanupTmpFiles(paths []string) { @@ -463,7 +464,8 @@ func (s *SignalClient) send(number string, message string, } func (s *SignalClient) About() About { - about := About{SupportedApiVersions: []string{"v1", "v2"}, BuildNr: 2, Mode: getSignalCliModeString(s.signalCliMode)} + about := About{SupportedApiVersions: []string{"v1", "v2"}, BuildNr: 2, Mode: getSignalCliModeString(s.signalCliMode), + Version: utils.GetEnv("BUILD_VERSION", "unset")} return about }