mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
Merge pull request #544 from mpldr/makefile-improvements
This commit is contained in:
commit
556ca5fec7
4
Makefile
4
Makefile
@ -1,5 +1,5 @@
|
|||||||
# Calculate version
|
# Calculate version
|
||||||
version = $(shell ./scripts/version-at-commit.sh)
|
version = $(git describe --always --tags --dirty)
|
||||||
|
|
||||||
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ PROTO_SOURCES = $(call rwildcard,,*.proto)
|
|||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
GGO_ENABLED=0 go build -ldflags "-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$(version)" cmd/headscale/headscale.go
|
CGO_ENABLED=0 go build -trimpath -buildmode=pie -mod=readonly -ldflags "-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$(version)" cmd/headscale/headscale.go
|
||||||
|
|
||||||
dev: lint test build
|
dev: lint test build
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e -o pipefail
|
|
||||||
commit="$1"
|
|
||||||
versionglob="v[0-9].[0-9]*.[0-9]*"
|
|
||||||
devsuffix=".dev"
|
|
||||||
if [ -z "$commit" ]; then
|
|
||||||
commit=`git log -n1 --first-parent "--format=format:%h"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# automatically assign version
|
|
||||||
#
|
|
||||||
# handles the following cases:
|
|
||||||
#
|
|
||||||
# 0. no tags on the repository. Print "dev".
|
|
||||||
#
|
|
||||||
# 1. no local modifications and commit is directly tagged. Print tag.
|
|
||||||
#
|
|
||||||
# 2. no local modifications and commit is not tagged. Take greatest version tag in repo X.Y.Z and assign X.Y.(Z+1). Print that + $devsuffix + $timestamp.
|
|
||||||
#
|
|
||||||
# 3. local modifications. Print "dev".
|
|
||||||
|
|
||||||
tags=$(git tag)
|
|
||||||
if [[ -z "$tags" ]]; then
|
|
||||||
echo "dev"
|
|
||||||
elif `git diff --quiet 2>/dev/null`; then
|
|
||||||
tagged=$(git tag --points-at "$commit")
|
|
||||||
if [[ -n "$tagged" ]] ; then
|
|
||||||
echo $tagged
|
|
||||||
else
|
|
||||||
nearest_tag=$(git describe --tags --abbrev=0 --match "$versionglob" "$commit")
|
|
||||||
v=$(echo $nearest_tag | perl -pe 's/(\d+)$/$1+1/e')
|
|
||||||
isodate=$(TZ=UTC git log -n1 --format=%cd --date=iso "$commit")
|
|
||||||
ts=$(TZ=UTC date --date="$isodate" "+%Y%m%d%H%M%S")
|
|
||||||
echo "${v}${devsuffix}${ts}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "dev"
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user