webhookd/Makefile

79 lines
1.5 KiB
Makefile
Raw Normal View History

2014-09-19 18:46:04 +00:00
.SILENT :
export GO111MODULE=on
# App name
APPNAME=webhookd
# Go configuration
GOOS?=linux
GOARCH?=amd64
# Add exe extension if windows target
is_windows:=$(filter windows,$(GOOS))
EXT:=$(if $(is_windows),".exe","")
2014-09-19 18:46:04 +00:00
# Artefact name
ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT)
# 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
all: build
2014-09-19 18:46:04 +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
## Clean built files
clean:
-rm -rf release
.PHONY: clean
2014-11-10 16:37:54 +00:00
## Build executable
2019-01-03 15:58:07 +00:00
build:
-mkdir -p release
2018-07-24 16:02:57 +00:00
echo "Building: $(ARTEFACT) $(VERSION) ..."
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o $(ARTEFACT)
.PHONY: build
2014-11-10 16:37:54 +00:00
$(ARTEFACT): build
## Run tests
test:
2019-01-03 15:58:07 +00:00
go test `go list ./... | grep -v vendor`
.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
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