Merge pull request #342 from firezone/fix-version-in-production

Add git_sha script
This commit is contained in:
Jamil
2021-12-15 19:08:14 -08:00
committed by GitHub
11 changed files with 24 additions and 26 deletions

View File

@@ -130,6 +130,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
env:
GIT_SHA: ${{ github.sha }}
run: |
. $HOME/.asdf/asdf.sh
cd omnibus

View File

@@ -1,7 +1,7 @@
defmodule FzCommon.MixProject do
use Mix.Project
@version_path "../../version.exs"
@version_path "../../scripts/version.exs"
def version do
Code.eval_file(@version_path)
@@ -16,7 +16,7 @@ defmodule FzCommon.MixProject do
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.11",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
deps: deps()
]

View File

@@ -142,7 +142,7 @@
</div>
<div class="level-right">
<div class="level-item">
<a href={"https://github.com/firezone/firezone/tree/#{github_sha()}"}>
<a href={"https://github.com/firezone/firezone/tree/#{git_sha()}"}>
Version <%= application_version() %>
</a>
</div>

View File

@@ -23,8 +23,8 @@ defmodule FzHttpWeb.LayoutView do
The current github sha, used to link to our Github repo.
This is set during application compile time.
"""
def github_sha do
Application.get_env(:fz_http, :github_sha, "master")
def git_sha do
Application.fetch_env!(:fz_http, :git_sha)
end
@doc """

View File

@@ -1,7 +1,7 @@
defmodule FzHttp.MixProject do
use Mix.Project
@version_path "../../version.exs"
@version_path "../../scripts/version.exs"
def version do
Code.eval_file(@version_path)
@@ -16,7 +16,7 @@ defmodule FzHttp.MixProject do
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.11",
elixir: "~> 1.12",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,

View File

@@ -1,7 +1,7 @@
defmodule FzVpn.MixProject do
use Mix.Project
@version_path "../../version.exs"
@version_path "../../scripts/version.exs"
def version do
Code.eval_file(@version_path)
@@ -16,7 +16,7 @@ defmodule FzVpn.MixProject do
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.11",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [

View File

@@ -1,7 +1,7 @@
defmodule FzWall.MixProject do
use Mix.Project
@version_path "../../version.exs"
@version_path "../../scripts/version.exs"
def version do
Code.eval_file(@version_path)
@@ -16,7 +16,7 @@ defmodule FzWall.MixProject do
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.11",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [

View File

@@ -26,13 +26,14 @@ require Logger
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
github_sha =
case System.cmd("git", ["rev-parse", "--short", "HEAD"], stderr_to_stdout: true) do
{result, 0} ->
result |> String.trim()
git_sha =
case System.get_env("GIT_SHA") do
nil ->
{output, 0} = System.cmd("git", ["rev-parse", "--short", "HEAD"], stderr_to_stdout: true)
String.trim(output)
{_, _} ->
nil
str ->
str
end
config :fz_http,
@@ -41,7 +42,7 @@ config :fz_http,
connectivity_checks_enabled: true,
connectivity_checks_interval: 3_600,
connectivity_checks_url: "https://ping-dev.firez.one/",
github_sha: github_sha,
git_sha: git_sha,
cookie_signing_salt: "Z9eq8iof",
ecto_repos: [FzHttp.Repo],
admin_email: "firezone@localhost",

View File

@@ -5,7 +5,7 @@ defmodule FirezoneUmbrella.MixProject do
use Mix.Project
@version_path "version.exs"
@version_path "scripts/version.exs"
def version do
Code.eval_file(@version_path)

2
scripts/version.exs Normal file
View File

@@ -0,0 +1,2 @@
{result, 0} = System.cmd(Path.join([__DIR__, "semver.sh"]), [], stderr_to_stdout: true)
result |> String.trim()

View File

@@ -1,7 +0,0 @@
case System.cmd(Path.join([__DIR__, "scripts", "semver.sh"]), []) do
{result, 0} ->
result |> String.trim()
{_, _} ->
"0.0.0"
end