Skip to content

Commit

Permalink
update Makefile to release to GitHub release with make release
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Apr 14, 2019
1 parent bb1192c commit fcd3aef
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
BIN := gojq
VERSION := $$(make -s show-version)
VERSION_PATH := cli
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-X github.com/itchyny/$(BIN)/cli.revision=$(CURRENT_REVISION)"
export GO111MODULE=on
Expand All @@ -14,9 +16,14 @@ build:
install:
go install -ldflags=$(BUILD_LDFLAGS) ./...

.PHONY: show-version
show-version:
@GO111MODULE=off go get github.com/motemen/gobump/cmd/gobump
@gobump show -r $(VERSION_PATH)

.PHONY: cross
cross: crossdeps
goxz -n $(BIN) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)
goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)

.PHONY: crossdeps
crossdeps:
Expand All @@ -38,3 +45,24 @@ lintdeps:
clean:
rm -rf build goxz
go clean

.PHONY: bump
bump:
@git status --porcelain | grep "^" && echo "git workspace is dirty" >/dev/stderr && exit 1 || :
gobump set $(shell sh -c 'read -p "input next version (current: $(VERSION)): " v && echo $$v') -w $(VERSION_PATH)
git commit -am "bump up version to $(VERSION)"
git tag "v$(VERSION)"
git push
git push --tags

.PHONY: crossdocker
crossdocker:
docker run --rm -v `pwd`:"/$${PWD##*/}" -w "/$${PWD##*/}" golang make cross

.PHONY: upload
upload:
GO111MODULE=off go get github.com/tcnksm/ghr
ghr "v$(VERSION)" goxz

.PHONY: release
release: test lint clean bump crossdocker upload

0 comments on commit fcd3aef

Please sign in to comment.