-
Notifications
You must be signed in to change notification settings - Fork 211
/
Makefile
50 lines (37 loc) · 2 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
.PONY: all build deps image lint test
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: lint test build ## Run the tests and build the binary.
os = darwin
arch = amd64
build:
@echo "Making gocommerce for $(os)/$(arch)"
GOOS=$(os) GOARCH=$(arch) go build -ldflags "-X github.com/netlify/gocommerce/cmd.Version=`git rev-parse HEAD`"
build_linux: override os=linux
build_linux: build
package: build
tar -czf gocommerce-$(os)-$(arch).tar.gz gocommerce
package_linux: override os=linux
package_linux: package
release: ## Upload release to GitHub releases.
mkdir -p builds/darwin-${TAG}
GOOS=darwin GOARCH=$(arch) go build -ldflags "-X github.com/netlify/gocommerce/cmd.Version=`git rev-parse HEAD`" -o builds/darwin-${TAG}/gocommerce
mkdir -p builds/linux-${TAG}
GOOS=linux GOARCH=$(arch) go build -ldflags "-X github.com/netlify/gocommerce/cmd.Version=`git rev-parse HEAD`" -o builds/linux-${TAG}/gocommerce
mkdir -p builds/windows-${TAG}
GOOS=windows GOARCH=$(arch) go build -ldflags "-X github.com/netlify/gocommerce/cmd.Version=`git rev-parse HEAD`" -o builds/windows-${TAG}/gocommerce.exe
@rm -rf releases/${TAG}
mkdir -p releases/${TAG}
tar -czf releases/${TAG}/gocommerce-darwin-$(arch)-${TAG}.tar.gz -C builds/darwin-${TAG} gocommerce
tar -czf releases/${TAG}/gocommerce-linux-$(arch)-${TAG}.tar.gz -C builds/linux-${TAG} gocommerce
zip -j releases/${TAG}/gocommerce-windows-$(arch)-${TAG}.zip builds/windows-${TAG}/gocommerce.exe
@hub release create -a releases/${TAG}/gocommerce-darwin-$(arch)-${TAG}.tar.gz -a releases/${TAG}/gocommerce-linux-$(arch)-${TAG}.tar.gz -a releases/${TAG}/gocommerce-windows-$(arch)-${TAG}.zip v${TAG}
deps: ## Install dependencies.
@go get -u golang.org/x/lint/golint
@go mod download
image: ## Build the Docker image.
docker build .
lint: ## Lint the code
golint `go list ./... | grep -v /vendor/`
test: ## Run tests.
go test -v -race ./...