-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix incorrect .PHONY clause for the binary. - Change `dist` to the more conventional `build`. - Rename binary to `kaf-relay` from `kaf-relay.bin`. - Make version string construction more robust.
- Loading branch information
Showing
2 changed files
with
17 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# Git version for injecting into Go bins. | ||
LAST_COMMIT := $(shell git rev-parse --short HEAD) | ||
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT}) | ||
VERSION := $(shell git describe --tags) | ||
BUILDSTR := ${VERSION} (Commit: ${LAST_COMMIT_DATE} (${LAST_COMMIT}), Build: $(shell date +"%Y-%m-%d% %H:%M:%S %z")) | ||
# Try to get the commit hash from 1) git 2) the VERSION file 3) fallback. | ||
LAST_COMMIT := $(or $(shell git rev-parse --short HEAD 2> /dev/null),$(shell head -n 1 VERSION | grep -oP -m 1 "^[a-z0-9]+$$"),"") | ||
|
||
BIN := kaf-relay.bin | ||
DIST := dist | ||
# Try to get the semver from 1) git 2) the VERSION file 3) fallback. | ||
VERSION := $(or $(LISTMONK_VERSION),$(shell git describe --tags --abbrev=0 2> /dev/null),$(shell grep -oP 'tag: \Kv\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?' VERSION),"v0.0.0") | ||
BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")) | ||
|
||
.PHONY: dist | ||
dist: | ||
mkdir -p ${DIST} | ||
CGO_ENABLED=1 go build -o ${BIN} --ldflags="-X 'main.buildString=${BUILDSTR}'" | ||
cp ${BIN} ${DIST} | ||
BIN := kaf-relay | ||
|
||
.PHONY: build | ||
build: $(BIN) | ||
|
||
$(BIN): | ||
CGO_ENABLED=0 go build -o ${BIN} --ldflags="-X 'main.buildString=${BUILDSTR}'" | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf ${DIST} | ||
rm -rf ${BIN} |