summaryrefslogtreecommitdiffstats
path: root/release
blob: 9182d53faf40cfd5a7ee68e10494b91ca4a88e4f (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

# Usage: ./release NEW_VERSION [ dev | SINCE_COMMITISH ]
# 
# If "dev" is supplied as the second argument, a development snapshot
# is done rather than a real release, i.e.:
#    * the --snapshot --auto options are passed to git-dch
#    * no commit or tag is created
# else, the second argument is passed to git-dch's --since option.

### source the configuration files

. config/amnesia
if [ -e config/amnesia.local ] ; then
   . config/amnesia.local
fi

### init variables

NEW_VERSION="$1"
if [ "$2" = dev ]; then
   SNAPSHOT=yes
else
   SNAPSHOT=no
   SINCE="$2"
fi

### helper functions

fatal () {
   echo "Fatal: $@" >&2
   exit 2
}

### sanity checks

[ -n "${NEW_VERSION}" ] \
   || fatal "the new version must be supplied on the command-line."
[ -n "${AMNESIA_DEV_FULLNAME}" ] \
   || fatal "AMNESIA_DEV_FULLNAME must be set in config/amnesia"
[ -n "${AMNESIA_DEV_EMAIL}" ] \
   || fatal "AMNESIA_DEV_EMAIL must be set in config/amnesia"
[ -n "${AMNESIA_DEV_KEYID}" ] \
   || fatal "AMNESIA_DEV_KEYID must be set in config/amnesia"
[ -x "`which git`" ] \
   || fatal "could not find git, please apt-get install git-core"
[ -x "`which git-dch`" ] \
   || fatal "could not find git-dch, please apt-get install git-buildpackage"

### main

export DEBFULLNAME="${AMNESIA_DEV_FULLNAME}"
export DEBEMAIL="${AMNESIA_DEV_EMAIL}"

# update the Changelog
echo "Updating debian/changelog from Git history..."
git-dch \
   `if [ ${SNAPSHOT} = yes ]; then echo '--snapshot --auto' ; fi` \
   `if [ ${SNAPSHOT} = no -a -n ${SINCE} ]; then echo "--release --since=${SINCE}" ; fi` \
   `if [ ${SNAPSHOT} = no -a -z ${SINCE} ]; then echo "--release --auto" ; fi` \
   --new-version="${NEW_VERSION}" \
   --ignore-branch \
   || fatal "git-dch failed."

# commit and tag the release
# if [ "${SNAPSHOT}" = no ]; then
#    echo "Commit'ing debian/changelog..."
#    git commit -m "releasing version ${NEW_VERSION}" debian/changelog \
#       || fatal "failed to commit debian/changelog"
#    echo "Tagging new version..."
#    git tag -u "${AMNESIA_DEV_KEYID}" -m "tagging version ${NEW_VERSION}" "${NEW_VERSION}"
# fi

echo "done."