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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
#!/usr/bin/env bash
# puts the public files online after a release
# Copyright (c) 2006-2016 Willy Tarreau <w@1wt.eu>
#
# In short :
# - requires git
# - no restriction to master, uses last tag
# - copies & compresses files, changelog & docs to the final destination
# - shows a listing of the final file
USAGE="Usage: ${0##*/} [-a] [-q] [-y] [-b branch] [-n newver] DIR"
CMD_GZIP="${CMD_GZIP:-gzip -nc9}"
TARGET_DIR=
OUTPUT=
SAYYES=
BRANCH=
DEVEL=
QUIET=
AUTO=
ARG0="$0"
NEW=
DIR=
DOC=( )
die() {
[ "$#" -eq 0 ] || echo "$*" >&2
exit 1
}
err() {
echo "$*" >&2
}
quit() {
[ "$#" -eq 0 -o -n "$QUIET" ] || echo "$*"
exit 0
}
while [ -n "$1" -a -z "${1##-*}" ]; do
case "$1" in
-a) AUTO=1 ; shift ;;
-q) QUIET=1 ; shift ;;
-y) SAYYES=1 ; shift ;;
-b) BRANCH="$2" ; shift 2 ;;
-n) NEW="$2" ; shift 2 ;;
-h|--help) quit "$USAGE" ;;
*) die "$USAGE" ;;
esac
done
if [ $# -ne 1 ]; then
die "$USAGE"
fi
DIR="$1" ; shift
if [ -z "$DIR" ]; then
die "Missing target directory name."
fi
if [ -n "${DIR##/*}" ]; then
DIR="$PWD/$DIR"
fi
if [ ! -d "$DIR/." ]; then
die "Target directory doesn't exist : $DIR"
fi
if ! git rev-parse --verify -q HEAD >/dev/null; then
die "Failed to check git HEAD."
fi
# we want to go to the git top dir
toplvl=$(git rev-parse --show-toplevel)
if [ -n "$toplvl" ]; then
cd "$toplvl"
fi
# ensure that a master branch exists here
if [ -z "$(git rev-parse --verify -q master 2>/dev/null)" ]; then
die "Current directory doesn't seem to be a valid git directory (no master branch)."
fi
if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then
die "git HEAD doesn't match master branch."
fi
if [ "$(git diff HEAD 2>/dev/null |wc -c)" != 0 ]; then
err "You appear to have uncommitted local changes, please commit them first :"
git status -s -uno >&2
die
fi
if [ -z "$NEW" -o -n "$AUTO" ]; then
if [ -z "$NEW" ]; then
NEW="$(git describe --tags HEAD --abbrev=0)"
NEW="${NEW#v}"
if [ -z "$NEW" ]; then
die "Fatal: cannot determine new version, please specify it."
fi
fi
if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then
if [ -n "$AUTO" ]; then
quit "Not tagged, nothing to do."
fi
die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?"
fi
fi
if ! git show-ref --tags "v$NEW" >/dev/null; then
die "git tag v$NEW doesn't exist, did you create the release ?"
fi
# determine the product branch from the new release
if [ -z "$BRANCH" ]; then
subvers=${NEW#[0-9]*.[0-9]*[-.]*[0-9].}
[ "${subvers}" = "${NEW}" ] && subvers=""
major=${NEW%.$subvers}
branch_ext=${major#*[0-9].*[0-9]}
BRANCH=${major%${branch_ext}}
fi
TARGET_DIR="$DIR/$BRANCH"
if [ ! -d "$TARGET_DIR/." ]; then
die "Target directory doesn't contain branch $BRANCH. You may have to create it in $DIR."
fi
if [ -z "${NEW##*-dev*}" ]; then
DEVEL="/devel"
fi
if [ -n "$AUTO" -a -e "$TARGET_DIR/src${DEVEL}/haproxy-$NEW.tar.gz.md5" ]; then
quit "Version $NEW Already released."
fi
if ! mkdir -p "$TARGET_DIR/src$DEVEL" "$TARGET_DIR/doc"; then
die "failed to create target directories."
fi
case "$BRANCH" in
1.3) DOC=( doc/{haproxy-en,haproxy-fr,configuration,architecture}.txt ) ;;
1.4) DOC=( doc/{haproxy-en,haproxy-fr,configuration}.txt ) ;;
1.5) DOC=( doc/{coding-style,configuration,proxy-protocol}.txt ) ;;
1.6) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua}.txt ) ;;
*) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua,SPOE}.txt ) ;;
esac
if [ -z "$AUTO" ]; then
echo "Ready to produce the following files in $TARGET_DIR/ :"
echo " haproxy-$NEW.tar.gz -> src${DEVEL}/"
echo " CHANGELOG -> src/CHANGELOG"
echo " ${DOC[@]} -> doc/*{,.gz}"
echo
git ls-tree -l --abbrev=12 "v$NEW" -- CHANGELOG "${DOC[@]}"
if [ -z "$SAYYES" ]; then
echo "Press ENTER to continue or Ctrl-C to abort now!"
read
fi
fi
echo "Archiving sources for version $NEW ..."
rm -f "${TARGET_DIR}/src${DEVEL}/haproxy-${NEW}.tar.gz"{,.md5,.sha256}
if ! git archive --format=tar --prefix="haproxy-${NEW}/" "v$NEW" | \
$CMD_GZIP > "${TARGET_DIR}/src${DEVEL}/haproxy-${NEW}.tar.gz"; then
die "Failed to produce the tar.gz archive"
fi
( cd "$TARGET_DIR/src${DEVEL}" ; \
md5sum haproxy-$NEW.tar.gz > haproxy-$NEW.tar.gz.md5 ; \
sha256sum haproxy-$NEW.tar.gz > haproxy-$NEW.tar.gz.sha256 )
echo "Extracting doc ..."
git show "v$NEW:CHANGELOG" > "$TARGET_DIR/src/CHANGELOG"
for i in "${DOC[@]}"; do
git show "v$NEW:$i" > "$TARGET_DIR/doc/${i#doc/}"
$CMD_GZIP < "$TARGET_DIR/doc/${i#doc/}" > "$TARGET_DIR/doc/${i#doc/}.gz"
done
if [ -x "${ARG0%/*}/make-releases-json" ]; then
# regenerate versions
"${ARG0%/*}/make-releases-json" -o "$TARGET_DIR/src/releases.json" "$TARGET_DIR"
fi
echo "Done : ls -l ${TARGET_DIR}"
( cd "$TARGET_DIR" ;
ls -l src/CHANGELOG "src${DEVEL}/haproxy-${NEW}".tar.gz{,.md5,.sha256} $(for i in "${DOC[@]}"; do echo "doc/${i#doc/}"{,.gz}; done)
)
echo
|