lyricdownloader/Makefile

48 lines
1.0 KiB
Makefile

# Inspired from https://dustinspecker.com/posts/go-combined-unit-integration-code-coverage/ and https://netdevops.me/2023/test-coverage-for-go-integration-tests/
BIN_DIR = $(CURDIR)/artifacts
BINARY = $(BIN_DIR)/lyricdownloader
CURRENT_DIR = $(shell pwd)
CUR_TAG = $(shell git tag | sort -g | tail -1 | cut -c 2-)
VERSION_NUMBER ?= 0.0.0
ifneq ($(CI_COMMIT_TAG),)
VERSION_NUMBER := $(CI_COMMIT_TAG:v%=%)
else
VERSION_NUMBER := ${CUR_TAG}
endif
.PHONY: clean
clean:
go clean
.PHONY: dep
dep:
go mod tidy
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: lint
lint:
golangci-lint run
.PHONY: build
build:
go build -o $(BINARY)
.PHONY: release
release:
mv ${BINARY} ${BINARY}-${VERSION_NUMBER}
cd ${BIN_DIR}
mkdir ${BIN_DIR}/tmp
mv ${BINARY}-${VERSION_NUMBER} ${BIN_DIR}/tmp
# From here https://www.baeldung.com/linux/tar-archive-without-directory-structure
tar -zcvf ${BINARY}-${VERSION_NUMBER}.tar.gz -C ${BIN_DIR}/tmp .
rm -rf ${BIN_DIR}/tmp
cd ${CURRENT_DIR}
.PHONY: lint-all
lint-all:
golangci-lint run --enable-all