-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
63 lines (50 loc) · 1.53 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
# Use a single bash shell for each job, and immediately exit on failure
SHELL := bash
.SHELLFLAGS := -ceu
.ONESHELL:
# This doesn't work on directories.
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
.DELETE_ON_ERROR:
# Don't print the commands in the file unless you specify VERBOSE. This is
# essentially the same as putting "@" at the start of each line.
ifndef VERBOSE
.SILENT:
endif
# Create the output directories if they do not exist.
$(shell mkdir -p build)
VERSION := $(shell ./scripts/version.sh)
clean:
rm -rf build
.PHONY: clean
fmt:
go fmt ./...
.PHONY: fmt
lint:
golangci-lint run
.PHONY: lint
build: build/tunneld build/tunnel
.PHONY: build
# build/tunneld and build/tunnel build the Go binary for the current
# architecture. You can change the architecture by setting GOOS and GOARCH
# manually before calling this target.
build/tunneld build/tunnel: build/%: $(shell find . -type f -name '*.go')
CGO_ENABLED=0 go build \
-o "$@" \
-tags urfave_cli_no_docs \
-ldflags "-s -w -X 'github.com/coder/wgtunnel/buildinfo.tag=$(VERSION)'" \
"./cmd/$*"
# build/tunneld.tag generates the Docker image for tunneld.
build/tunneld.tag: build/tunneld
# Dev versions contain plus signs which are illegal in Docker tags.
version="$(VERSION)"
tag="ghcr.io/coder/wgtunnel/tunneld:$${version//+/-}"
docker build \
--file Dockerfile \
--build-arg "WGTUNNEL_VERSION=$(VERSION)" \
--tag "$$tag" \
.
echo "$$tag" > "$@"
test:
go clean -testcache
gotestsum -- -v -short ./...
.PHONY: test