Read version from file

This commit is contained in:
Adrian Kumpf
2020-10-04 18:55:22 +02:00
parent 8adadaf724
commit ca11558992
4 changed files with 18 additions and 7 deletions

View File

@@ -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

View File

@@ -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 .

1
VERSION Normal file
View File

@@ -0,0 +1 @@
1.21.0-dev

View File

@@ -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