diff --git a/Makefile b/Makefile index 5189fe4afe..076a050904 100644 --- a/Makefile +++ b/Makefile @@ -292,14 +292,14 @@ docker-watcher_info-prod: docker-watcher-build: docker build -f Dockerfile.watcher \ - --build-arg release_version=$$(cat $(PWD)/VERSION)+$$(git rev-parse --short=7 HEAD) \ + --build-arg release_version=$$(git describe --tags) \ --cache-from $(WATCHER_IMAGE_NAME) \ -t $(WATCHER_IMAGE_NAME) \ . docker-watcher_info-build: docker build -f Dockerfile.watcher_info \ - --build-arg release_version=$$(cat $(PWD)/VERSION)+$$(git rev-parse --short=7 HEAD) \ + --build-arg release_version=$$(git describe --tags) \ --cache-from $(WATCHER_INFO_IMAGE_NAME) \ -t $(WATCHER_INFO_IMAGE_NAME) \ . diff --git a/VERSION b/VERSION deleted file mode 100644 index 90a27f9cea..0000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.5 diff --git a/apps/omg/mix.exs b/apps/omg/mix.exs index 783c4ea117..e774cb63ac 100644 --- a/apps/omg/mix.exs +++ b/apps/omg/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.MixProject do def project() do [ app: :omg, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -24,6 +24,14 @@ defmodule OMG.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. # :dev compiles `test/support` to gain access to various `Support.*` helpers defp elixirc_paths(:prod), do: ["lib"] diff --git a/apps/omg_bus/mix.exs b/apps/omg_bus/mix.exs index 43bd9736a4..f191036a9f 100644 --- a/apps/omg_bus/mix.exs +++ b/apps/omg_bus/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.Bus.MixProject do def project() do [ app: :omg_bus, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -25,6 +25,14 @@ defmodule OMG.Bus.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/omg_conformance/mix.exs b/apps/omg_conformance/mix.exs index ab8a04bf87..60cf536b0b 100644 --- a/apps/omg_conformance/mix.exs +++ b/apps/omg_conformance/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.Conformance.MixProject do def project() do [ app: :omg_conformance, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -23,6 +23,14 @@ defmodule OMG.Conformance.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] defp elixirc_paths(:test), do: ["lib", "test/support"] diff --git a/apps/omg_db/mix.exs b/apps/omg_db/mix.exs index b48a216ce0..660ae7b4ac 100644 --- a/apps/omg_db/mix.exs +++ b/apps/omg_db/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.DB.MixProject do def project() do [ app: :omg_db, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -25,6 +25,14 @@ defmodule OMG.DB.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/omg_eth/mix.exs b/apps/omg_eth/mix.exs index dbee8a9b4f..3f6a03c998 100644 --- a/apps/omg_eth/mix.exs +++ b/apps/omg_eth/mix.exs @@ -6,7 +6,7 @@ defmodule OMG.Eth.MixProject do def project() do [ app: :omg_eth, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -27,6 +27,14 @@ defmodule OMG.Eth.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. # :dev compiles `test/support` to gain access to various `Support.*` helpers defp elixirc_paths(:prod), do: ["lib"] diff --git a/apps/omg_status/mix.exs b/apps/omg_status/mix.exs index 442319692f..21bbc6a767 100644 --- a/apps/omg_status/mix.exs +++ b/apps/omg_status/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.Status.Mixfile do def project() do [ app: :omg_status, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -31,6 +31,14 @@ defmodule OMG.Status.Mixfile do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + defp deps(), do: [ {:telemetry, "~> 0.4.1"}, diff --git a/apps/omg_utils/mix.exs b/apps/omg_utils/mix.exs index bd3a252a20..b2bb8f40ad 100644 --- a/apps/omg_utils/mix.exs +++ b/apps/omg_utils/mix.exs @@ -4,7 +4,7 @@ defmodule Utils.MixProject do def project() do [ app: :omg_utils, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -21,6 +21,14 @@ defmodule Utils.MixProject do [extra_applications: [:plug]] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/omg_watcher/mix.exs b/apps/omg_watcher/mix.exs index e9236360ae..78397dce25 100644 --- a/apps/omg_watcher/mix.exs +++ b/apps/omg_watcher/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.Watcher.MixProject do def project() do [ app: :omg_watcher, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -26,6 +26,14 @@ defmodule OMG.Watcher.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/omg_watcher_info/mix.exs b/apps/omg_watcher_info/mix.exs index e9bc3e7828..16c69f8560 100644 --- a/apps/omg_watcher_info/mix.exs +++ b/apps/omg_watcher_info/mix.exs @@ -4,7 +4,7 @@ defmodule OMG.WatcherInfo.MixProject do def project() do [ app: :omg_watcher_info, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -26,6 +26,14 @@ defmodule OMG.WatcherInfo.MixProject do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/omg_watcher_rpc/mix.exs b/apps/omg_watcher_rpc/mix.exs index bfa3693155..e4080f0ce3 100644 --- a/apps/omg_watcher_rpc/mix.exs +++ b/apps/omg_watcher_rpc/mix.exs @@ -2,9 +2,16 @@ defmodule OMG.WatcherRPC.Mixfile do use Mix.Project def project() do + version = + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + [ app: :omg_watcher_rpc, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", @@ -25,6 +32,14 @@ defmodule OMG.WatcherRPC.Mixfile do ] end + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end + # Specifies which paths to compile per environment. defp elixirc_paths(:prod), do: ["lib"] defp elixirc_paths(:dev), do: ["lib"] diff --git a/apps/xomg_tasks/mix.exs b/apps/xomg_tasks/mix.exs index 874d5f0d87..e87a7c237e 100644 --- a/apps/xomg_tasks/mix.exs +++ b/apps/xomg_tasks/mix.exs @@ -9,7 +9,7 @@ defmodule OMG.XomgTasks.MixProject do def project() do [ app: :xomg_tasks, - version: "#{String.trim(File.read!("../../VERSION"))}", + version: version(), build_path: "../../_build", deps_path: "../../deps", lockfile: "../../mix.lock", @@ -23,4 +23,12 @@ defmodule OMG.XomgTasks.MixProject do def application() do [extra_applications: [:iex, :logger]] end + + defp version() do + "git" + |> System.cmd(["describe", "--tags", "--abbrev=0"]) + |> elem(0) + |> String.replace("v", "") + |> String.replace("\n", "") + end end diff --git a/mix.exs b/mix.exs index 2a216b1703..fed576b03e 100644 --- a/mix.exs +++ b/mix.exs @@ -166,8 +166,10 @@ defmodule OMG.Umbrella.MixProject do defp docker(), do: if(System.get_env("DOCKER"), do: "_docker", else: "") defp current_version() do - sha = String.replace(elem(System.cmd("git", ["rev-parse", "--short=7", "HEAD"]), 0), "\n", "") - "#{String.trim(File.read!("VERSION"))}" <> "+" <> sha + "git" + |> System.cmd(["describe", "--tags"]) + |> elem(0) + |> String.replace("\n", "") end defp steps() do