🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add git info to version
Deluan8756f5565026
diff --git a/Dockerfile b/Dockerfileindex 3b3cbbb35..1b712a8f0 100644--- a/Dockerfile+++ b/Dockerfile@@ -17,6 +17,12 @@ RUN mkdir -p /src/ui/buildRUN apk add -U --no-cache build-base gitRUN go get -u github.com/go-bindata/go-bindata/...+# Download and unpack static ffmpeg+ARG FFMPEG_VERSION=4.1.4+ARG FFMPEG_URL=https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz+RUN wget -O /tmp/ffmpeg.tar.xz ${FFMPEG_URL}+RUN cd /tmp && tar xJf ffmpeg.tar.xz && rm ffmpeg.tar.xz+# Download project dependenciesWORKDIR /srcCOPY go.mod go.sum ./@@ -30,13 +36,6 @@ COPY --from=jsbuilder /src/build/static/js/* /src/ui/build/static/js/RUN rm -rf /src/build/css /src/build/jsRUN make buildall-# Download and unpack static ffmpeg-ARG FFMPEG_VERSION=4.1.4-ARG FFMPEG_URL=https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz-RUN wget -O /tmp/ffmpeg.tar.xz ${FFMPEG_URL}-RUN cd /tmp && tar xJf ffmpeg.tar.xz && rm ffmpeg.tar.xz--######################################################## Build Final ImageFROM alpinediff --git a/Makefile b/Makefileindex 603a4ef9c..8f667d490 100644--- a/Makefile+++ b/Makefile@@ -1,6 +1,11 @@GO_VERSION=1.13NODE_VERSION=v13.7.0+GIT_HASH=$(shell git rev-parse --short HEAD)+GIT_BRANCH=$(shell git symbolic-ref --short -q HEAD)+GIT_TAG=$(shell git describe --tags --abbrev=0 2> /dev/null)+GIT_COUNT=$(shell git rev-list HEAD --count)+.PHONY: devdev: check_env data@goreman -f Procfile.dev -b 4533 start@@ -22,10 +27,6 @@ test: check_go_envtestall: check_go_env test@(cd ./ui && npm test -- --watchAll=false)-.PHONY: build-build: check_go_env- go build-.PHONY: setupsetup: Jamstash-master@which reflex || (echo "Installing Reflex" && GO111MODULE=off go get -u github.com/cespare/reflex)@@ -69,7 +70,12 @@ ui/build: $(UI_SRC) $(UI_PUBLIC) ui/package-lock.jsonassets/embedded_gen.go: ui/buildgo-bindata -fs -prefix "ui/build" -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/...+.PHONY: build+build: check_go_env+ go build -ldflags="-X main.gitCount=$(GIT_COUNT) -X main.gitHash=$(GIT_HASH) -X main.gitBranch=$(GIT_BRANCH) -X main.gitTag=$(GIT_TAG)"+.PHONY: buildallbuildall: check_go_env assets/embedded_gen.go- go build -tags embed+ go build -ldflags="-X main.gitCount=$(GIT_COUNT) -X main.gitHash=$(GIT_HASH) -X main.gitBranch=$(GIT_BRANCH) -X main.gitTag=$(GIT_TAG)" \+ -tags embeddiff --git a/banner.go b/banner.gonew file mode 100644index 000000000..83f86f55d--- /dev/null+++ b/banner.go@@ -0,0 +1,42 @@+package main++import (+ "fmt"+ "strings"++ "github.com/deluan/navidrome/static"+)++var (+ // This will be set in build time. If not, version will be set to "dev"+ gitBranch string+ gitTag string+ gitHash string+ gitCount string+)++// Formats:+// dev+// v0.2.0 (596-5b84188)+// master (600-9ed35cb)+func getVersion() string {+ if gitHash == "" {+ return "dev"+ }+ version := fmt.Sprintf(" (%s-%s)", gitCount, gitHash)+ if gitTag != "" {+ return gitTag + version+ }+ return gitBranch + version+}++func getBanner() string {+ data, _ := static.Asset("banner.txt")+ return strings.TrimSuffix(string(data), "\n")+}++func ShowBanner() {+ version := "Version: " + getVersion()+ padding := strings.Repeat(" ", 52-len(version))+ fmt.Printf("%s%s%s\n\n", getBanner(), padding, version)+}diff --git a/main.go b/main.goindex 301a7dd52..6f98fa1c8 100644--- a/main.go+++ b/main.go@@ -1,18 +1,9 @@package mainimport (- "fmt"-"github.com/deluan/navidrome/conf"- "github.com/deluan/navidrome/server"- "github.com/deluan/navidrome/static")-func ShowBanner() {- banner, _ := static.Asset("banner.txt")- fmt.Printf(string(banner), server.Version)-}-func main() {conf.Load()diff --git a/server/server.go b/server/server.goindex 4fd51e614..f31b99027 100644--- a/server/server.go+++ b/server/server.go@@ -15,8 +15,6 @@ import ("github.com/go-chi/cors")-const Version = "0.2.0"-type Server struct {Scanner *scanner.Scannerrouter *chi.Muxdiff --git a/static/banner.txt b/static/banner.txtindex ab4be2902..cd6828ec8 100644--- a/static/banner.txt+++ b/static/banner.txt@@ -4,5 +4,3 @@| . ` |/ _` \ \ / / |/ _` | '__/ _ \| '_ ` _ \ / _ \| |\ | (_| |\ V /| | (_| | | | (_) | | | | | | __/\_| \_/\__,_| \_/ |_|\__,_|_| \___/|_| |_| |_|\___|- Version %s-diff --git a/static/bindata.go b/static/bindata.goindex 3877216be..0d0191c5e 100644--- a/static/bindata.go+++ b/static/bindata.go@@ -150,7 +150,6 @@ var _bannerTxt = []byte(` _ _ _ _| . ` + "`" + ` |/ _` + "`" + ` \ \ / / |/ _` + "`" + ` | '__/ _ \| '_ ` + "`" + ` _ \ / _ \| |\ | (_| |\ V /| | (_| | | | (_) | | | | | | __/\_| \_/\__,_| \_/ |_|\__,_|_| \___/|_| |_| |_|\___|- Version %s`)@@ -164,7 +163,7 @@ func bannerTxt() (*asset, error) {return nil, err}- info := bindataFileInfo{name: "banner.txt", size: 317, mode: os.FileMode(420), modTime: time.Unix(1579927428, 0)}+ info := bindataFileInfo{name: "banner.txt", size: 267, mode: os.FileMode(420), modTime: time.Unix(1579965459, 0)}a := &asset{bytes: bytes, info: info}return a, nil}