diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 620b0291ca..8aeb3e4bff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -484,7 +484,10 @@ jobs: - name: Set version run: | - VERSION=${{ steps.latest-tag.outputs.tag }} + git config --global --add safe.directory /__w/web/web + VERSION=$(./hack/get_version_from_git.sh) + # "+" character is not allowed in OBS dockerfile version strings + VERSION=${VERSION//[+]/-} sed -i 's~%%VERSION%%~'"${VERSION}"'~' packaging/suse/Dockerfile - name: Commit on OBS diff --git a/hack/get_version_from_git.sh b/hack/get_version_from_git.sh index 6fee3489dc..c811cd1de6 100755 --- a/hack/get_version_from_git.sh +++ b/hack/get_version_from_git.sh @@ -1,4 +1,7 @@ #!/bin/sh +set -e +set -o pipefail + TAG=$( git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1 ) if [ -n "${TAG}" ]; then diff --git a/mix.exs b/mix.exs index 25f0aa3c28..eecc002ca7 100644 --- a/mix.exs +++ b/mix.exs @@ -1,11 +1,13 @@ defmodule Trento.MixProject do use Mix.Project + @version "1.1.0" + def project do [ app: :trento, description: "Easing your life in administering SAP applications", - version: "1.1.0", + version: get_version(), elixir: "~> 1.13", elixirc_paths: elixirc_paths(Mix.env()), compilers: Mix.compilers(), @@ -121,4 +123,13 @@ defmodule Trento.MixProject do ] ] end + + defp get_version, do: System.get_env("VERSION", get_version_from_git()) + + defp get_version_from_git do + case File.cwd!() |> Path.join("hack/get_version_from_git.sh") |> System.cmd([]) do + {version, 0} -> version |> String.trim("\n") + _ -> @version + end + end end diff --git a/packaging/suse/Dockerfile b/packaging/suse/Dockerfile index e475481bb7..0820918de2 100644 --- a/packaging/suse/Dockerfile +++ b/packaging/suse/Dockerfile @@ -22,7 +22,7 @@ ENV MIX_ENV=prod ENV MIX_HOME=/usr/bin ENV FLAVOR="Premium" RUN mix phx.digest -RUN mix release +RUN VERSION=%%VERSION%% mix release FROM bci/bci-base:15.3 AS trento # Define labels according to https://en.opensuse.org/Building_derived_containers