-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (44 loc) · 1.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
51
52
53
54
55
56
57
58
APPNAME := toolchained
MYOS := $(shell uname)
BUILD_DATE ?= $(strip $(shell date -u +"%Y-%m-%dT%H:%M:%SZ"))
VERSION ?= $(shell cat VERSION)
VENDOR ?= Toolchained
PROJECT_NAME ?= toolchained-cli
DOCKER_IMAGE ?= $(VENDOR)/$(PROJECT_NAME)
GIT_TAG ?= $(strip $(shell git rev-parse --abbrev-ref HEAD | tr '/' '-'))
GIT_URL ?= $(strip $(shell git config --get remote.origin.url))
# Find out if the working directory is clean
GIT_NOT_CLEAN_CHECK = $(shell git status --porcelain)
default: build
build: go_build
install: go_install
setup: dep_init
release: go_release
# Get the version number from the code
GIT_TAG = v$(strip $(shell cat GIT_TAG))
ifndef GIT_TAG
$(error You need to create a GIT_TAG file to deploy)
endif
go_build:
cd $(APPNAME)
go build -o mypackage
cd ..
go_install:
cd $(APPNAME)
go install
cd ..
dep_init:
go get -u github.com/spf13/cobra/cobra
go get github.com/goreleaser/goreleaser
go get -u github.com/golang/dep/cmd/dep
mkdir -p $(APPNAME)
cobra init ./$(APPNAME)
dep init
git_tag:
./script/bump.sh
git tag -a $(GIT_TAG) -m "First release"
git push origin $(GIT_TAG)
go_release:
git_tag
goreleaser
.PHONY: release setup install build go_build go_install dep_init git_tag go_release