forked from dgiot/dgiot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkg-vsn.sh
executable file
·35 lines (28 loc) · 863 Bytes
/
pkg-vsn.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
set -euo pipefail
# This script prints the release version for emqx
# ensure dir
cd -P -- "$(dirname -- "$0")"
if [ -f EMQX_ENTERPRISE ]; then
EDITION='enterprise'
else
EDITION='opensource'
fi
## emqx_release.hrl is the single source of truth for release version
RELEASE="$(grep -E "define.+EMQX_RELEASE.+${EDITION}" include/emqx_release.hrl | cut -d '"' -f2)"
git_exact_vsn() {
local tag
tag="$(git describe --tags --match "[e|v]*" --exact 2>/dev/null)"
echo "$tag" | sed 's/^[v|e]//g'
}
GIT_EXACT_VSN="$(git_exact_vsn)"
if [ "$GIT_EXACT_VSN" != '' ]; then
if [ "$GIT_EXACT_VSN" != "$RELEASE" ]; then
echo "ERROR: Tagged $GIT_EXACT_VSN, but $RELEASE in include/emqx_release.hrl" 1>&2
exit 1
fi
SUFFIX=''
else
SUFFIX="-$(git rev-parse HEAD | cut -b1-8)"
fi
echo "${RELEASE}${SUFFIX}"