From b7d1d91309cbf815f73a576bf236e5994057f1a4 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 12 Apr 2021 13:47:58 +0200 Subject: [PATCH] For untagged commits, include hash in version name (fixes #1563) --- .dockerignore | 1 - crates/utils/src/version.rs | 2 +- docker/dev/Dockerfile | 1 + docker/dev/volume_mount.dockerfile | 1 + docker/prod/Dockerfile | 1 + docker/prod/Dockerfile.arm | 1 + docker/prod/deploy.sh | 6 ------ 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3a0f82b48..b3bb4eb26 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,5 +4,4 @@ docker api_tests ansible tests -.git *.sh diff --git a/crates/utils/src/version.rs b/crates/utils/src/version.rs index 397d2a429..ac0896a3c 100644 --- a/crates/utils/src/version.rs +++ b/crates/utils/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "0.10.3"; +pub const VERSION: &str = "unknown version"; diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 5d2acec7f..4b7dc3ad4 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -36,6 +36,7 @@ COPY --from=cacher /home/rust/.cargo /home/rust/.cargo COPY ./ ./ RUN sudo chown -R rust:rust . +RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" RUN cargo build # reduce binary size diff --git a/docker/dev/volume_mount.dockerfile b/docker/dev/volume_mount.dockerfile index 00d9c4735..6d9fa996c 100644 --- a/docker/dev/volume_mount.dockerfile +++ b/docker/dev/volume_mount.dockerfile @@ -9,6 +9,7 @@ WORKDIR /app # Copy the source folders COPY . ./ +RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" # Build for debug RUN --mount=type=cache,target=/usr/local/cargo/registry \ diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 75c53e675..b869a7667 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -9,6 +9,7 @@ WORKDIR /app COPY ./ ./ RUN sudo chown -R rust:rust . +RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" RUN cargo build --release # reduce binary size diff --git a/docker/prod/Dockerfile.arm b/docker/prod/Dockerfile.arm index b3eacb4f9..01f24456e 100644 --- a/docker/prod/Dockerfile.arm +++ b/docker/prod/Dockerfile.arm @@ -11,6 +11,7 @@ RUN apt-get update \ WORKDIR /app COPY ./ ./ +RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" RUN cargo build --release diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh index 7520f1495..d72a74e8e 100755 --- a/docker/prod/deploy.sh +++ b/docker/prod/deploy.sh @@ -6,12 +6,6 @@ set -e new_tag="$1" third_semver=$(echo $new_tag | cut -d "." -f 3) -# Setting the version on the backend -pushd ../../ -echo "pub const VERSION: &str = \"$new_tag\";" > "crates/utils/src/version.rs" -git add "crates/utils/src/version.rs" -popd - # The ansible and docker installs should only update for non release-candidates # IE, when the third semver is a number, not '2-rc' if [ ! -z "${third_semver##*[!0-9]*}" ]; then