Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.

Commit 458aebf

Browse files
committed
build: Add automatic version
1 parent d1e9d55 commit 458aebf

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
)
99

10-
const (
10+
var (
1111
// version of Convoy
1212
VERSION = "0.5.0-dev"
1313
)

scripts/build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22
set -e
33

4+
source $(dirname $0)/version
5+
46
cd $(dirname $0)/..
57

8+
echo Current building version is $VERSION
9+
610
mkdir -p bin
711
go build -a -tags "netgo libdm_no_deferred_remove" \
812
-ldflags "-X main.VERSION=$VERSION -linkmode external -extldflags -static" \

scripts/version

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
4+
DIRTY="-dirty"
5+
fi
6+
7+
COMMIT=$(git rev-parse --short HEAD)
8+
GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
9+
10+
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
11+
VERSION=$GIT_TAG
12+
else
13+
VERSION="${COMMIT}${DIRTY}"
14+
fi

0 commit comments

Comments
 (0)