-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
106 lines (87 loc) · 1.93 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
SHELL := bash
.ONESHELL:
NAME := swage
BUILD_DIR := bin
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
VERSION := $(file < ./VERSION)
# GOBIN := $(shell go env GOPATH)/bin
# TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
MAKEFLAGS += --warn-undefined-variables
# go tool link (https://golang.org/cmd/link/)
LDFLAGS := -s -w -extldflags='-static' -X 'github.com/markruler/swage/cmd.swageVersion=$(VERSION)'
all: version deps test cover build
.PHONY: all
version:
@echo $(VERSION)
.PHONY: version
deps:
@#go get -u
@#rm -rf vendor/
@go get -t -d -v ./...
@go mod tidy
@go mod vendor
.PHONY: deps
fmt:
go fmt ./...
.PHONY: fmt
lint:
golangci-lint run ./...
@#golangci-lint linters
@#golangci-lint run --enable revive
@#golangci-lint run --enable-all
.PHONY: lint
test: fmt
go test ./... --cover
.PHONY: test
# make test-unit package=./cmd unit=TestSnapshotVersion
test-unit: fmt
go test ${package} -v -run ${unit}
.PHONY: test
testv: fmt
go test ./... -v
.PHONY: testv
test-verbose-cover: fmt
go test ./... -v --cover
.PHONY: testv
cover:
@scripts/cover --html
@scripts/cover
.PHONY: cover
run:
go run main.go
.PHONY: run
clean:
go clean
rm -f *.xlsx
rm -rf $(BIN_DIR)
rm -rf dist
.PHONY: clean
build: test
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BUILD_DIR)/$(NAME) -v -ldflags="${LDFLAGS}" main.go
.PHONY: build
docker:
scripts/docker.sh
.PHONY: docker
release-test:
rm -rf dist
goreleaser --snapshot --skip-publish
.PHONY: release
# https://github.com/settings/tokens
# - [x] repo_deployment
# - [x] public_repo
release-publish:
# Update VERSION
# Update README.md
# git commit
rm -rf dist
git tag $(VERSION)
goreleaser release --rm-dist
# git push origin main
.PHONY: release-publish
tag-remove:
git push --delete origin $(VERSION)
git tag -d $(VERSION)
.PHONY: tag-remove