fix(ci): Populate elixir vsn from env at build time (#7773)

Dependabot's workflow is set up in such a way it seems that it can't
find our `sha.exs` file.

This is a cleaner approach that doesn't rely on using external files for
the application version.

Interesting note: `mix compile` will happily use the cached `version`
even though it's computed from an env var, because `mix compile` uses
file hash and mtime to know when to recompile.

See https://github.com/firezone/firezone/network/updates/942719116
This commit is contained in:
Jamil
2025-01-16 14:26:22 -08:00
committed by GitHub
parent ce2de2ec8d
commit 53032fcbe1
6 changed files with 29 additions and 25 deletions

View File

@@ -2,11 +2,9 @@ defmodule API.MixProject do
use Mix.Project
def project do
{sha, _} = Code.eval_file(Path.join([__DIR__, "..", "..", "sha.exs"]))
[
app: :api,
version: "0.1.0+#{sha}",
version: version(),
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
@@ -79,4 +77,9 @@ defmodule API.MixProject do
test: ["ecto.create --quiet", "ecto.migrate", "test"]
]
end
defp version do
sha = System.get_env("GIT_SHA", "deadbeef") |> String.trim()
"0.1.0+#{sha}"
end
end