-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
61 lines (53 loc) · 1.78 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
# Project information
OWNER := tomohiro
REPOSITORY := $(shell basename $(PWD))
VERSION := $(shell grep "const Version " $(PWD)/version.go | sed -E 's/.*"(.+)"$$/\1/')
REVISION := $(shell git rev-parse --short HEAD)
# Build information
DIST_DIR := $(PWD)/dist
ASSETS_DIR := $(DIST_DIR)/$(VERSION)
XC_OS := "linux darwin windows"
XC_ARCH := "386 amd64"
BUILD_LDFLAGS := "-w -s -X main.revision=$(REVISION)"
# Tasks
.PHONY: help
help:
@echo "Please type: make [target]"
@echo " setup Setup development environment"
@echo " deps Install runtime dependencies"
@echo " updatedeps Update runtime dependencies"
@echo " dist Ship packages as release assets"
@echo " release Publish release assets to GitHub"
@echo " clean Cleanup assets"
@echo " help Show this help messages"
.PHONY: setup
setup:
@echo "===> Setup development tools..."
# Install goxz - Just do cross building and archiving go tools conventionally
GO111MODULE=off go get github.com/Songmu/goxz/cmd/goxz
# Install ghr - Upload multiple artifacts to GitHub Release in parallel
GO111MODULE=off go get github.com/tcnksm/ghr
.PHONY: deps
deps:
@echo "===> Installing runtime dependencies..."
go mod download
.PHONY: updatedeps
updatedeps:
@echo "===> Updating runtime dependencies..."
go get -u
.PHONY: dist
dist:
@echo "===> Shipping packages as release assets..."
goxz -z -pv=$(VERSION) -d=$(ASSETS_DIR) -os=$(XC_OS) -arch=$(XC_ARCH) --build-ldflags=$(BUILD_LDFLAGS)
pushd $(ASSETS_DIR); \
shasum -a 256 *.zip > ./$(VERSION)_SHA256SUMS; \
popd
.PHONY: release
release:
@echo "===> Publishing to GitHub..."
ghr -u=$(OWNER) -r=$(REPOSITORY) $(VERSION) $(ASSETS_DIR)
.PHONY: clean
clean:
@echo "===> Cleaning assets..."
go clean ./...
rm -rf $(DIST_DIR)