2020-03-06 07:50:39 -09:00
|
|
|
GO_VERSION=$(shell grep -e "^go " go.mod | cut -f 2 -d ' ')
|
|
|
|
|
NODE_VERSION=$(shell cat .nvmrc)
|
2020-01-13 18:53:23 -09:00
|
|
|
|
2020-01-26 08:36:24 -09:00
|
|
|
GIT_SHA=$(shell git rev-parse --short HEAD)
|
2020-04-20 05:47:44 -08:00
|
|
|
GIT_TAG=$(shell git describe --tags `git rev-list --tags --max-count=1`)
|
2020-01-25 07:06:04 -09:00
|
|
|
|
2020-03-20 08:21:41 -08:00
|
|
|
## Default target just build the Go project.
|
|
|
|
|
default:
|
|
|
|
|
go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/deluan/navidrome/consts.gitTag=master"
|
|
|
|
|
.PHONY: default
|
|
|
|
|
|
2020-01-30 12:08:39 -09:00
|
|
|
dev: check_env
|
2020-04-28 19:24:57 -08:00
|
|
|
npx foreman -j Procfile.dev -p 4533 start
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: dev
|
2020-01-19 18:48:36 -09:00
|
|
|
|
2020-01-30 12:08:39 -09:00
|
|
|
server: check_go_env
|
2020-01-20 09:43:51 -09:00
|
|
|
@reflex -d none -c reflex.conf
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: server
|
2020-01-20 09:43:51 -09:00
|
|
|
|
2020-04-04 18:23:20 -08:00
|
|
|
wire: check_go_env
|
|
|
|
|
wire ./...
|
|
|
|
|
.PHONY: wire
|
|
|
|
|
|
2020-01-15 19:40:22 -09:00
|
|
|
watch: check_go_env
|
|
|
|
|
ginkgo watch -notify ./...
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: watch
|
2020-01-15 19:40:22 -09:00
|
|
|
|
2020-01-13 18:53:23 -09:00
|
|
|
test: check_go_env
|
|
|
|
|
go test ./... -v
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: test
|
2020-01-13 18:53:23 -09:00
|
|
|
|
2020-01-19 15:34:54 -09:00
|
|
|
testall: check_go_env test
|
|
|
|
|
@(cd ./ui && npm test -- --watchAll=false)
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: testall
|
2020-01-19 15:34:54 -09:00
|
|
|
|
2020-05-09 17:00:38 -08:00
|
|
|
update-snapshots: check_go_env
|
|
|
|
|
UPDATE_SNAPSHOTS=true ginkgo ./server/subsonic/...
|
|
|
|
|
.PHONY: update-snapshots
|
|
|
|
|
|
2020-07-31 05:55:44 -08:00
|
|
|
migration:
|
2020-08-19 07:18:30 -08:00
|
|
|
@if [ -z "${name}" ]; then echo "Usage: make migration name=name_of_migration_file"; exit 1; fi
|
|
|
|
|
goose -dir db/migrations create ${name}
|
2020-07-31 05:55:44 -08:00
|
|
|
.PHONY: migration
|
2020-06-08 13:29:09 -08:00
|
|
|
|
2020-04-17 18:11:58 -08:00
|
|
|
setup:
|
2020-01-30 12:08:39 -09:00
|
|
|
@which go-bindata || (echo "Installing BinData" && GO111MODULE=off go get -u github.com/go-bindata/go-bindata/...)
|
2020-04-26 12:10:40 -08:00
|
|
|
go mod download
|
2020-04-29 04:29:20 -08:00
|
|
|
@(cd ./ui && npm ci)
|
2020-04-26 12:10:40 -08:00
|
|
|
.PHONY: setup
|
|
|
|
|
|
2020-07-16 13:52:59 -08:00
|
|
|
setup-dev: setup setup-git
|
2020-05-07 07:57:07 -08:00
|
|
|
@which wire || (echo "Installing Wire" && GO111MODULE=off go get -u github.com/google/wire/cmd/wire)
|
|
|
|
|
@which ginkgo || (echo "Installing Ginkgo" && GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo)
|
|
|
|
|
@which goose || (echo "Installing Goose" && GO111MODULE=off go get -u github.com/pressly/goose/cmd/goose)
|
|
|
|
|
@which reflex || (echo "Installing Reflex" && GO111MODULE=off go get -u github.com/cespare/reflex)
|
2020-05-18 08:29:19 -08:00
|
|
|
@which golangci-lint || (echo "Installing GolangCI-Lint" && cd .. && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0)
|
2020-07-16 13:52:59 -08:00
|
|
|
@which goimports || (echo "Installing goimports" && GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports)
|
2020-07-16 12:57:19 -08:00
|
|
|
.PHONY: setup-dev
|
2016-10-10 16:27:09 -08:00
|
|
|
|
2020-07-16 13:52:59 -08:00
|
|
|
setup-git:
|
|
|
|
|
@mkdir -p .git/hooks
|
|
|
|
|
(cd .git/hooks && ln -sf ../../git/* .)
|
|
|
|
|
.PHONY: setup-git
|
|
|
|
|
|
2020-01-13 18:53:23 -09:00
|
|
|
check_env: check_go_env check_node_env
|
2020-06-04 16:13:25 -08:00
|
|
|
.PHONY: check_env
|
2016-10-10 16:27:09 -08:00
|
|
|
|
2020-01-13 18:53:23 -09:00
|
|
|
check_go_env:
|
2020-01-26 11:32:55 -09:00
|
|
|
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
|
2020-02-26 05:37:48 -09:00
|
|
|
@go version | grep -q $(GO_VERSION) || (echo "\nERROR: Please upgrade your GO version\nThis project requires version $(GO_VERSION)"; exit 1)
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: check_go_env
|
2016-10-10 16:27:09 -08:00
|
|
|
|
2020-01-13 18:53:23 -09:00
|
|
|
check_node_env:
|
|
|
|
|
@(hash node) || (echo "\nERROR: Node environment not setup properly!\n"; exit 1)
|
|
|
|
|
@node --version | grep -q $(NODE_VERSION) || (echo "\nERROR: Please check your Node version. Should be $(NODE_VERSION)\n"; exit 1)
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: check_node_env
|
2020-01-08 07:13:05 -09:00
|
|
|
|
2020-01-25 07:06:04 -09:00
|
|
|
build: check_go_env
|
2020-04-25 05:27:22 -08:00
|
|
|
go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/deluan/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT"
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: build
|
2020-01-25 07:06:04 -09:00
|
|
|
|
2020-02-04 11:02:43 -09:00
|
|
|
buildall: check_env
|
2020-02-03 04:42:15 -09:00
|
|
|
@(cd ./ui && npm run build)
|
2020-05-01 10:35:57 -08:00
|
|
|
go-bindata -fs -prefix "resources" -tags embed -ignore="\\\*.go" -pkg resources -o resources/embedded_gen.go resources/...
|
2020-02-03 04:42:15 -09:00
|
|
|
go-bindata -fs -prefix "ui/build" -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/...
|
2020-04-25 05:27:22 -08:00
|
|
|
go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/deluan/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT" -tags=embed
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: buildall
|
2020-01-30 12:33:27 -09:00
|
|
|
|
|
|
|
|
release:
|
|
|
|
|
@if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi
|
|
|
|
|
go mod tidy
|
|
|
|
|
@if [ -n "`git status -s`" ]; then echo "\n\nThere are pending changes. Please commit or stash first"; exit 1; fi
|
2020-02-03 16:13:32 -09:00
|
|
|
make test
|
2020-01-30 12:33:27 -09:00
|
|
|
git tag v${V}
|
|
|
|
|
git push origin v${V}
|
2020-03-20 08:21:41 -08:00
|
|
|
.PHONY: release
|
2020-01-30 12:33:27 -09:00
|
|
|
|
2020-04-04 10:36:23 -08:00
|
|
|
snapshot:
|
2020-08-07 09:36:00 -08:00
|
|
|
docker run -it -v $(PWD):/workspace -w /workspace deluan/ci-goreleaser:1.14.4-3 goreleaser release --rm-dist --skip-publish --snapshot
|
2020-04-04 10:36:23 -08:00
|
|
|
.PHONY: snapshot
|