-
Notifications
You must be signed in to change notification settings - Fork 39
/
dist.sh
executable file
·58 lines (47 loc) · 1.13 KB
/
dist.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
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
#!/bin/sh -e
show_help() {
cat <<EOF
$0 [-r revision]
Simple shell script to create and sign tarball source distribution of NAV
Invocation with no arguments will create a tarball from the HEAD of the
current repository.
EOF
}
REVISION=$(git describe)
# Parse arguments
OPTIND=1
while getopts "hr:" opt; do
case $opt in
h) show_help
exit 0;
;;
r) REVISION="$OPTARG"
;;
*)
show_help >&2
exit 1
;;
esac
done
DIST_NAME="nav-$REVISION"
TARBALL="${DIST_NAME}.tar.gz"
archive() {
umask 0022
git rev-parse "$REVISION" >/dev/null || return 1
git archive --format=tar --prefix="$DIST_NAME/" "$REVISION" \
| gzip - > "$TARBALL"
}
if [ -f $TARBALL ]; then
echo "Tarball already exists: $TARBALL"
echo "Please remove it."
exit 1
fi
echo "Exporting archive of NAV revision $REVISION ..."
if archive; then
echo "MD5SUM:"; md5sum "$TARBALL"
echo "SHA1SUM:"; sha1sum "$TARBALL"
echo "Please sign the tarball"
gpg --armor --detach-sign "$TARBALL"
echo "All done. Enjoy your tarball:."
ls -la "$TARBALL"*
fi