forked from kevinburke/hostsfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (49 loc) · 2.04 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
.PHONY: test release
SHELL = /bin/bash -o pipefail
BUMP_VERSION := $(GOPATH)/bin/bump_version
STATICCHECK := $(GOPATH)/bin/staticcheck
RELEASE := $(GOPATH)/bin/github-release
WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap
UNAME := $(shell uname)
test:
go test ./...
$(STATICCHECK):
go get honnef.co/go/tools/cmd/staticcheck
$(BUMP_VERSION):
go get -u github.com/kevinburke/bump_version
$(RELEASE):
go get -u github.com/aktau/github-release
$(WRITE_MAILMAP):
go get -u github.com/kevinburke/write_mailmap
force: ;
AUTHORS.txt: force | $(WRITE_MAILMAP)
$(WRITE_MAILMAP) > AUTHORS.txt
authors: AUTHORS.txt
lint: | $(STATICCHECK)
$(STATICCHECK) ./...
go vet ./...
race-test: lint
go test -race ./...
# Run "GITHUB_TOKEN=my-token make release version=0.x.y" to release a new version.
release: race-test | $(BUMP_VERSION) $(RELEASE)
ifndef version
@echo "Please provide a version"
exit 1
endif
ifndef GITHUB_TOKEN
@echo "Please set GITHUB_TOKEN in the environment"
exit 1
endif
$(BUMP_VERSION) --version=$(version) cmd.go
git push origin --tags
mkdir -p releases/$(version)
# Change the binary names below to match your tool name
GOOS=linux GOARCH=amd64 go build -o releases/$(version)/hostsfile-linux-amd64 .
GOOS=darwin GOARCH=amd64 go build -o releases/$(version)/hostsfile-darwin-amd64 .
GOOS=windows GOARCH=amd64 go build -o releases/$(version)/hostsfile-windows-amd64 .
# Change the Github username to match your username.
# These commands are not idempotent, so ignore failures if an upload repeats
$(RELEASE) release --user kevinburke --repo hostsfile --tag $(version) || true
$(RELEASE) upload --user kevinburke --repo hostsfile --tag $(version) --name hostsfile-linux-amd64 --file releases/$(version)/hostsfile-linux-amd64 || true
$(RELEASE) upload --user kevinburke --repo hostsfile --tag $(version) --name hostsfile-darwin-amd64 --file releases/$(version)/hostsfile-darwin-amd64 || true
$(RELEASE) upload --user kevinburke --repo hostsfile --tag $(version) --name hostsfile-windows-amd64 --file releases/$(version)/hostsfile-windows-amd64 || true