diff --git a/Dockerfile b/Dockerfile index 3c06557e..cb7339bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ COPY lib lib COPY priv/repo/migrations priv/repo/migrations COPY priv/gettext priv/gettext COPY grafana/dashboards grafana/dashboards +COPY VERSION VERSION RUN mkdir -p /opt/built && \ mix "do" compile, release --path /opt/built diff --git a/Makefile b/Makefile index 26279bad..6e920b13 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,19 @@ -.PHONY: help grafana teslamate +.PHONY: help vsn grafana teslamate APP_NAME ?= `grep 'app:' mix.exs | sed -e 's/\[//g' -e 's/ //g' -e 's/app://' -e 's/[:,]//g'` -APP_VSN ?= `grep 'version:' mix.exs | cut -d '"' -f2` +APP_VSN ?= `cat VERSION` BUILD ?= `git rev-parse --short HEAD` -help: - @echo "$(APP_NAME):$(APP_VSN)-$(BUILD)" +help: vsn @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -teslamate: ## Build teslamate Docker image +vsn: + @echo "$(APP_NAME):$(APP_VSN)-$(BUILD)" + +teslamate: vsn ## Build teslamate Docker image @docker build --pull \ -t $(APP_NAME):$(APP_VSN)-$(BUILD) \ -t $(APP_NAME) . -grafana: ## Build teslamate-grafana Docker image +grafana: vsn ## Build teslamate-grafana Docker image @cd grafana && docker build --pull -t teslamate-grafana . diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..c6ba48dc --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.21.0-dev diff --git a/mix.exs b/mix.exs index 57687198..abc290eb 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule TeslaMate.MixProject do def project do [ app: :teslamate, - version: "1.20.0", + version: version(), elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), @@ -81,4 +81,11 @@ defmodule TeslaMate.MixProject do ] ] end + + defp version do + case File.read("VERSION") do + {:ok, version} -> String.trim(version) + {:error, _reason} -> "0.0.0" + end + end end