navidrome/Makefile

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

133 lines
4.3 KiB
Makefile
Raw Normal View History

GO_VERSION=$(shell grep "^go " go.mod | cut -f 2 -d ' ')
NODE_VERSION=$(shell cat .nvmrc)
2020-01-26 18:36:24 +01:00
GIT_SHA=$(shell git rev-parse --short HEAD)
GIT_TAG=$(shell git describe --tags `git rev-list --tags --max-count=1`)
2020-01-25 17:06:04 +01:00
## Default target just build the Go project.
default:
go build -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=master"
.PHONY: default
dev: check_dev_env
2020-04-29 05:24:57 +02:00
npx foreman -j Procfile.dev -p 4533 start
.PHONY: dev
2020-01-20 04:48:36 +01:00
server: check_go_dev_env
@go run github.com/cespare/reflex -d none -c reflex.conf
.PHONY: server
2020-04-05 04:23:20 +02:00
wire: check_go_env
go run github.com/google/wire/cmd/wire ./...
2020-04-05 04:23:20 +02:00
.PHONY: wire
watch: check_go_env
go run github.com/onsi/ginkgo/ginkgo watch -notify ./...
.PHONY: watch
test: check_go_env
go test ./... -v
.PHONY: test
2020-01-20 01:34:54 +01:00
testall: check_go_env test
@(cd ./ui && npm test -- --watchAll=false)
.PHONY: testall
2020-01-20 01:34:54 +01:00
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run -v --timeout 5m
.PHONY: lint
2021-03-24 17:21:20 +01:00
lintall: check_node_dev_env lint
@(cd ./ui && npm run check-formatting && npm run lint)
.PHONY: lintall
update-snapshots: check_go_env
UPDATE_SNAPSHOTS=true go run github.com/onsi/ginkgo/ginkgo ./server/subsonic/...
.PHONY: update-snapshots
migration:
2020-08-19 17:18:30 +02:00
@if [ -z "${name}" ]; then echo "Usage: make migration name=name_of_migration_file"; exit 1; fi
go run github.com/pressly/goose/cmd/goose -dir db/migration create ${name}
.PHONY: migration
2020-10-03 17:01:16 +02:00
setup: download-deps
@echo Installing tools from tools.go
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
.PHONY: setup
2020-10-03 17:01:16 +02:00
download-deps:
2021-03-17 12:19:07 +01:00
@echo Downloading Go dependencies...
2021-03-17 15:33:40 +01:00
@go mod download -x
@go mod tidy # To revert any changes made by the `go mod download` command
2021-03-17 12:19:07 +01:00
@echo Downloading Node dependencies...
2020-10-03 17:01:16 +02:00
@(cd ./ui && npm ci)
.PHONY: download-deps
2020-07-16 23:52:59 +02:00
setup-dev: setup setup-git
2020-07-16 22:57:19 +02:00
.PHONY: setup-dev
2016-10-11 02:27:09 +02:00
2020-07-16 23:52:59 +02:00
setup-git:
2020-10-03 17:01:16 +02:00
@echo Setting up git hooks
2020-07-16 23:52:59 +02:00
@mkdir -p .git/hooks
2020-10-03 17:01:16 +02:00
@(cd .git/hooks && ln -sf ../../git/* .)
2020-07-16 23:52:59 +02:00
.PHONY: setup-git
check_dev_env: check_go_dev_env check_node_dev_env
.PHONY: check_dev_env
check_go_dev_env:
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
@current_go_version=`go version | cut -d ' ' -f 3 | cut -c3-` && \
echo "$(GO_VERSION) $$current_go_version" | \
tr ' ' '\n' | sort -V | tail -1 | \
grep -q "^$${current_go_version}$$" || \
(echo "\nERROR: Please upgrade your GO version\nThis project requires at least the version $(GO_VERSION)"; exit 1)
.PHONY: check_go_dev_env
check_node_dev_env:
@(hash node) || (echo "\nERROR: Node environment not setup properly!\n"; exit 1)
@current_node_version=`node --version` && \
echo "$(NODE_VERSION) $$current_node_version" | \
tr ' ' '\n' | sort -V | tail -1 | \
grep -q "^$${current_node_version}$$" || \
(echo "\nERROR: Please check your Node version. Should be at least $(NODE_VERSION)\n"; exit 1)
.PHONY: check_node_dev_env
check_env: check_go_env check_node_env
2020-06-05 02:13:25 +02:00
.PHONY: check_env
2016-10-11 02:27:09 +02:00
check_go_env:
2020-01-26 21:32:55 +01:00
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
2020-02-26 15:37:48 +01:00
@go version | grep -q $(GO_VERSION) || (echo "\nERROR: Please upgrade your GO version\nThis project requires version $(GO_VERSION)"; exit 1)
.PHONY: check_go_env
2016-10-11 02:27:09 +02: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)
.PHONY: check_node_env
2020-01-08 17:13:05 +01:00
2020-01-25 17:06:04 +01:00
build: check_go_env
go build -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT"
.PHONY: build
2020-01-25 17:06:04 +01:00
2020-02-04 21:02:43 +01:00
buildall: check_env
@(cd ./ui && npm run build)
go build -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)-SNAPSHOT" -tags=netgo
.PHONY: buildall
2021-03-24 17:21:20 +01:00
pre-push: lintall testall
.PHONY: pre-push
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
make pre-push
git tag v${V}
git push origin v${V} --no-verify
.PHONY: release
2020-04-04 20:36:23 +02:00
snapshot:
2021-03-12 21:14:07 +01:00
docker run -t -v $(PWD):/workspace -w /workspace deluan/ci-goreleaser:1.16.2-1 goreleaser release --rm-dist --skip-publish --snapshot
2020-04-04 20:36:23 +02:00
.PHONY: snapshot