-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.sh
executable file
·32 lines (29 loc) · 1.13 KB
/
version.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
#!/bin/sh
# ----------------------------------------------------------------------
# Copyright © 2011-2014, RedJack, LLC.
# All rights reserved.
#
# Please see the COPYING file in this distribution for license details.
# ----------------------------------------------------------------------
# Calculates the current version number. If possible, this is the
# output of “git describe”. If “git describe” returns an error (most
# likely because we're in an unpacked copy of a release tarball, rather
# than in a git working copy), then we fall back on reading the contents
# of the RELEASE-VERSION file.
#
# This will automatically update the RELEASE-VERSION file, if necessary.
# Note that the RELEASE-VERSION file should *not* be checked into git;
# please add it to your top-level .gitignore file.
version=$(git describe)
if [ -n ${version} ]; then
# If we got something from git-describe, write the version to the
# output file.
echo ${version} > RELEASE-VERSION
else
version=$(cat RELEASE-VERSION)
if [ -z ${version} ]; then
echo "Cannot find the version number!" >&2
exit 1
fi
fi
echo ${version}