This repository has been archived by the owner on Apr 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (43 loc) · 1.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
SHELL = /bin/bash
VERSION ?= 0.0.3
GIT_HASH = $(shell git rev-parse --short HEAD)
PROJECT_NAME = devon
BUILDKITE_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILDKITE_BUILD_NUMBER ?= 0
define GOLANG_CONTAINER
docker container run --rm \
--volume $(shell pwd):/go/src/github.com/redbubble/${PROJECT_NAME} \
--workdir /go/src/github.com/redbubble/${PROJECT_NAME} \
--env GO111MODULE=on \
--env CGO_ENABLED=0 \
--interactive golang:1.15
endef
.PHONY: test
test:
${GOLANG_CONTAINER} go test ./...
.PHONY: release
release:
ifeq (${GITHUB_TOKEN},)
$(error GITHUB_TOKEN is not set. Please populate it with your GitHub Personal Access token (https://github.com/settings/tokens))
endif
git tag -f -a "v${VERSION}" -m "Releasing version ${VERSION}"
git push --tags
GO111MODULE=on goreleaser --rm-dist
.PHONY: fmt
fmt:
${GOLANG_CONTAINER} go fmt ./...
git diff --exit-code
target/${PROJECT_NAME}:
mkdir -p target
${GOLANG_CONTAINER} go build -o $@ -ldflags "-s -X main.version=${VERSION}" -a -installsuffix cgo
.PHONY: install
install:
GO111MODULE=on go install -ldflags "-s -X main.version=${VERSION}" -a -installsuffix cgo
# .PHONY: completions
# completions: target/${PROJECT_NAME}
# target/${PROJECT_NAME} completions bash > static/completions/${PROJECT_NAME}.bash
# target/${PROJECT_NAME} completions zsh > static/completions/${PROJECT_NAME}.zsh
.PHONY: clean
clean: ## Cleanup artifacts generated by build.
@echo "--- :shower: Cleaning up :shower:"
rm -rf target