-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
45 lines (37 loc) · 1.32 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, version 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
NAME := github-release
VERSION := v1.1.0
build:
go build -ldflags "-X main.Version=$(VERSION)"
compile:
@rm -rf build/
@gox -ldflags "-X main.Version=$(VERSION)" \
-osarch="darwin/amd64" \
-os="linux" \
-os="windows" \
-os="solaris" \
-output "build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \
./...
install:
go install -ldflags "-X main.Version=$(VERSION)"
deps:
go get github.com/c4milo/github-release
go get github.com/mitchellh/gox
dist: compile
$(eval FILES := $(shell ls build))
@rm -rf dist && mkdir dist
@for f in $(FILES); do \
(cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \
(cd $(shell pwd)/dist && shasum -a 512 $$f.tar.gz > $$f.sha512); \
echo $$f; \
done
release: dist
@latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \
comparison="$$latest_tag..HEAD"; \
if [ -z "$$latest_tag" ]; then comparison=""; fi; \
changelog=$$(git log $$comparison --oneline --no-merges); \
github-release c4milo/$(NAME) $(VERSION) "$$(git rev-parse --abbrev-ref HEAD)" "**Changelog**<br/>$$changelog" 'dist/*'; \
git pull
.PHONY: build compile install deps dist release