Skip to content

Commit

Permalink
Read version from file
Browse files Browse the repository at this point in the history
  • Loading branch information
adriankumpf committed Oct 4, 2020
1 parent 8adadaf commit ca11558
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.21.0-dev
9 changes: 8 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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

0 comments on commit ca11558

Please sign in to comment.