forked from hyphanet/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag-build
executable file
·146 lines (113 loc) · 3.35 KB
/
tag-build
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Load configuration and utility functions.
source freenet-scripts-common || exit
cd "$fredDir"
DIFF="$(git diff)"
if [[ -n "$DIFF" ]]; then
echo "$DIFF"
echo There are modified files. Please commit or stash them.
exit 1
fi
# Testnet is a separate source repository, so we need to check for it.
# TODO we should have --testnet switches on the scripts.
if grep TESTNET src/freenet/node/Version.java ; then
echo This appears to be a testnet build because freenet.node.Version contains "TESTNET".
echo Testnet builds are not suitable for release as a normal build.
exit 2
fi
BUILD=$1
if [[ -z $BUILD ]]; then
echo Usage: tag-build 1234
echo 1234 is the build number.
exit 3
fi
if ! grep "buildNumber = $BUILD;" src/freenet/node/Version.java ; then
echo src/freenet/node/Version.java does not contain the requested build number.
echo Please update the build number, as well as - if desired - the mandatory date.
exit 4
fi
TAG=$(printf 'build%05d' "$BUILD")
PREVBUILD=$(($BUILD-1))
PREVTAG=$(printf 'build%05d' "$PREVBUILD")
FULLCHANGELOG=$releaseDir/changelog.full.$TAG.txt
CHANGELOG=$releaseDir/changelog.short.$TAG.txt
echo Releasing build $TAG
echo Previous build was $PREVTAG
# Don't overwrite an existing changelog.
if [ ! -e "$FULLCHANGELOG" ]; then
cat - > "$FULLCHANGELOG" <<EOF
$(date '+%F')
Changes in $BUILD:
[enumerate developer-facing changes]
- Release manager name
[include shortlogs of any installer or plugin changes]
---
$(git shortlog --no-merges "$PREVTAG..")
EOF
fi
editor $FULLCHANGELOG || exit 10
if [ ! -e "$CHANGELOG" ]; then
# TODO: 0.7.5 shouldn't be hardcoded in multiple places.
cat > "$CHANGELOG" <<EOF
$(date '+%F')
Freenet 0.7.5 build $BUILD is now available. [overview]
[enumerate user-facing changes]
Thank you for using Freenet!
- Release manager name
EOF
fi
editor $CHANGELOG || exit 11
# Temporary file to hold developer changelog, user-facing changelog, and contributing authors.
TEMP="$(mktemp)"
# Remove temporary file on exit.
function cleanup {
rm "$TEMP"
}
trap cleanup EXIT
cat "$CHANGELOG" > "$TEMP"
echo >> "$TEMP"
echo "Developer changelog:" >> "$TEMP"
echo >> "$TEMP"
cat "$FULLCHANGELOG" >> "$TEMP"
echo
echo Combined changelog as will be tagged:
echo
cat "$TEMP"
echo
require "Tag as $TAG?"
# Tag with the message, and push the tags and changes.
git tag "$gitSign" "$TAG" -F "$TEMP" || exit 8
git push origin "$TAG"
echo "$TAG" > "$releaseDir/freenet.tag" || exit 6
echo "$BUILD" > "$releaseDir/freenet.build" || exit 6
# TODO: test vs. [ ] or [[ ]]?
# Get the name of the active branch. TODO: More idiomatic?
BRANCH="$(git branch | grep "^\*" | cut -b 3-)"
if test $BRANCH != "master" && test $BRANCH != "next"; then
# Common case: Releasing from a branch, e.g. stable-9999, fixes
echo "Merging active branch $BRANCH back into master."
git checkout master
git merge -S --ff-only $TAG || exit 7
# Then offer to delete it.
echo "Delete branch $BRANCH? [y/N]"
read x
if [[ $x == "y" ]]; then
git branch -d $BRANCH
git push origin :$BRANCH
echo Deleted branch $BRANCH
else
git checkout $BRANCH
fi
# Merge master into next.
git checkout next
git merge -S master
elif test $BRANCH == "next"; then
# Releasing from next.
# Merge next into master.
git checkout master
git merge -S next
fi
# Push changes and end on next.
git push origin next
git push origin master
git checkout next