2014-09-19 18:46:04 +00:00
|
|
|
.SILENT :
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-12-18 19:52:03 +00:00
|
|
|
export GO111MODULE=on
|
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# App name
|
|
|
|
APPNAME=webhookd
|
2014-09-23 18:16:50 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Go configuration
|
|
|
|
GOOS?=linux
|
|
|
|
GOARCH?=amd64
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Add exe extension if windows target
|
|
|
|
is_windows:=$(filter windows,$(GOOS))
|
|
|
|
EXT:=$(if $(is_windows),".exe","")
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Artefact name
|
|
|
|
ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT)
|
2014-09-23 18:16:50 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Extract version infos
|
|
|
|
VERSION:=`git describe --tags`
|
2018-07-24 16:02:57 +00:00
|
|
|
LDFLAGS=-ldflags "-X main.Version=$(VERSION)"
|
2014-10-31 23:18:38 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
all: build
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Include common Make tasks
|
|
|
|
root_dir:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
makefiles:=$(root_dir)/makefiles
|
|
|
|
include $(makefiles)/help.Makefile
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Clean built files
|
|
|
|
clean:
|
|
|
|
-rm -rf release
|
|
|
|
.PHONY: clean
|
2014-11-10 16:37:54 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Build executable
|
2019-01-03 15:58:07 +00:00
|
|
|
build:
|
2018-01-02 16:11:59 +00:00
|
|
|
-mkdir -p release
|
2018-07-24 16:02:57 +00:00
|
|
|
echo "Building: $(ARTEFACT) $(VERSION) ..."
|
2018-01-02 16:11:59 +00:00
|
|
|
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o $(ARTEFACT)
|
|
|
|
.PHONY: build
|
2014-11-10 16:37:54 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
$(ARTEFACT): build
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Run tests
|
2014-09-25 12:18:20 +00:00
|
|
|
test:
|
2019-01-03 15:58:07 +00:00
|
|
|
go test `go list ./... | grep -v vendor`
|
2018-01-02 16:11:59 +00:00
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
## Install executable
|
|
|
|
install: $(ARTEFACT)
|
|
|
|
echo "Installing $(ARTEFACT) to ${HOME}/.local/bin/$(APPNAME) ..."
|
|
|
|
cp $(ARTEFACT) ${HOME}/.local/bin/$(APPNAME)
|
|
|
|
.PHONY: install
|
|
|
|
|
|
|
|
## Create Docker image
|
|
|
|
image:
|
|
|
|
echo "Building Docker inage ..."
|
|
|
|
docker build --rm -t ncarlier/$(APPNAME) .
|
|
|
|
.PHONY: image
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-02-12 20:18:33 +00:00
|
|
|
## Generate changelog
|
|
|
|
changelog:
|
|
|
|
standard-changelog --first-release
|
|
|
|
.PHONY: changelog
|
|
|
|
|
|
|
|
## GZIP executable
|
|
|
|
gzip:
|
2019-01-03 10:59:44 +00:00
|
|
|
gzip $(ARTEFACT)
|
2018-02-12 20:18:33 +00:00
|
|
|
.PHONY: gzip
|
|
|
|
|
|
|
|
## Create distribution binaries
|
|
|
|
distribution:
|
|
|
|
GOARCH=amd64 make build gzip
|
|
|
|
GOARCH=arm64 make build gzip
|
|
|
|
GOARCH=arm make build gzip
|
|
|
|
GOOS=darwin make build gzip
|
|
|
|
.PHONY: distribution
|
|
|
|
|