webhookd/Makefile
2019-01-09 10:36:47 +00:00

84 lines
1.7 KiB
Makefile

.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","")
# Archive name
ARCHIVE=$(APPNAME)-$(GOOS)-$(GOARCH).tgz
# Executable name
EXECUTABLE=$(APPNAME)$(EXT)
# Extract version infos
VERSION:=`git describe --tags`
LDFLAGS=-ldflags "-X main.Version=$(VERSION)"
all: build
# Include common Make tasks
root_dir:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
makefiles:=$(root_dir)/makefiles
include $(makefiles)/help.Makefile
## Clean built files
clean:
-rm -rf release
.PHONY: clean
## Build executable
build:
-mkdir -p release
echo "Building: $(EXECUTABLE) $(VERSION) for $(GOOS)-$(GOARCH) ..."
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o release/$(EXECUTABLE)
.PHONY: build
release/$(EXECUTABLE): build
## Run tests
test:
go test ./...
.PHONY: test
## Install executable
install: release/$(EXECUTABLE)
echo "Installing $(EXECUTABLE) to ${HOME}/.local/bin/$(EXECUTABLE) ..."
cp release/$(EXECUTABLE) ${HOME}/.local/bin/$(EXECUTABLE)
.PHONY: install
## Create Docker image
image:
echo "Building Docker image ..."
docker build --rm -t ncarlier/$(APPNAME) .
.PHONY: image
## Generate changelog
changelog:
standard-changelog --first-release
.PHONY: changelog
## Create archive
archive: release/$(EXECUTABLE)
echo "Creating release/$(ARCHIVE) archive..."
tar czf release/$(ARCHIVE) README.md LICENSE CHANGELOG.md -C release/ $(EXECUTABLE)
rm release/$(EXECUTABLE)
.PHONY: archive
## Create distribution binaries
distribution:
GOARCH=amd64 make build archive
GOARCH=arm64 make build archive
GOARCH=arm make build archive
GOOS=darwin make build archive
.PHONY: distribution