-
Notifications
You must be signed in to change notification settings - Fork 137
/
Makefile
35 lines (27 loc) · 908 Bytes
/
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
EXE := tfswitch
PKG := github.com/warrensbox/terraform-switcher
VER := $(shell git ls-remote --tags git@github.com:warrensbox/terraform-switcher.git | awk '{if ($$2 ~ "\\^\\{\\}$$") next; print vers[split($$2,vers,"\\/")]}' | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -1)
PATH := build:$(PATH)
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
$(EXE): go.mod *.go lib/*.go
go build -v -ldflags "-X main.version=$(VER)" -o $@ $(PKG)
.PHONY: release
release: $(EXE) darwin linux
.PHONY: darwin linux
darwin linux:
GOOS=$@ go build -ldflags "-X main.version=$(VER)" -o $(EXE)-$(VER)-$@-$(GOARCH) $(PKG)
.PHONY: clean
clean:
rm -f $(EXE) $(EXE)-*-*-*
.PHONY: test
test: $(EXE)
mv $(EXE) build
go test -v ./...
.PHONY: install
install: $(EXE)
mkdir -p ~/bin
mv $(EXE) ~/bin
.PHONY: docs
docs:
cd docs; bundle install --path vendor/bundler; bundle exec jekyll build -c _config.yml; cd ..