summaryrefslogtreecommitdiffstats
path: root/release
blob: 3236717d5adcf3eb9f71ae89a87fa292df2b9f73 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/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 gbp-dch
#    * no commit or tag is created
# else, the second argument is passed to gbp-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 gbp`" ] \
   || fatal "could not find gbp, 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..."
gbp dch \
   `if [ ${SNAPSHOT} = yes ]; then echo '--snapshot --auto' ; fi` \
   `if [ ${SNAPSHOT} = no -a -n ${SINCE} ]; then echo "--since=${SINCE}" ; fi` \
   `if [ ${SNAPSHOT} = no -a -z ${SINCE} ]; then echo "--auto" ; fi` \
   --new-version="${NEW_VERSION}" \
   --ignore-branch \
   -- '*' ':!wiki' \
   || fatal "gbp dch failed."

# cleanup some parts of the changelog
perl -pi'' -e 's/\A  \[ IkiWiki::Plugin::po::change \]\n//' debian/changelog
perl -pi'' -e 's/\A  \* update[d]? PO file[s]?[.]?\n//' debian/changelog
perl -pi'' -e 's/\A  \* \n//' debian/changelog
perl -pi'' -e 's/\A  \[ 127\.0\.0\.1 \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ amnesia \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ anonym \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ bertagaz \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ BitingBird \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ intrigeri \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ kytv \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ sajolida \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ T\(A\)ILS developers \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ Tails developers \]\n//' debian/changelog
perl -pi'' -e 's/\A  \[ Tails \]\n//' debian/changelog
perl -pi'' -e 's/\A  \* Added a comment\n//' debian/changelog
perl -pi'' -e 's/\A  \* Added a comment:.*\n//' debian/changelog
perl -pi'' -e 's/\A  \* Remove spam\.\n//' debian/changelog
perl -pi'' -e 's/\A  \* todo\+\+\n//i' debian/changelog
perl -pi'' -e 's/\A  \* todo--\n//i' debian/changelog
perl -pi'' -e 's/\A  \* TODO update[.]?\n//i' debian/changelog
perl -pi'' -e 's/\A  \* Update ticket[.]?\n//i' debian/changelog
perl -pi'' -e 's/\A  \* Now pending[.]?\n//i' debian/changelog
perl -pi'' -e 's/\A  \* Done[.]?\n//i' debian/changelog
perl -pi'' -e 's/\A  \* Upcoming release\n//' debian/changelog

# 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."