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
|
#!/bin/bash -e
# Tarball release script. See http://oar.imag.fr/wiki:tarball_release
confirm() {
read -n 1 -s -p "$1 " ANSWER
echo
if [ "$ANSWER" != "y" -a "$ANSWER" != "Y" ]; then
echo "Aborted!"
exit 1
fi
}
usage() {
cat <<EOF
$0 [<OPTIONS>] <ACTION>
Actions:
release
push-tags
push-ftp
drop-tags
all
Options:
-S This is a stable release
-V <version> Gives the version of the release
-r Gives git remote (multiple possible)
-v Verbose
-f <hostname> Gives the OAR FTP hostname for ssh
EOF
}
verbose() {
if [ -n "$VERBOSE" ]; then
set -x
fi
}
unverbose() {
set +x
}
release() {
if [ -z "$VERSION" ]; then
read -p "Version ? " VERSION
fi
confirm "Release tarball for OAR version $VERSION ?"
git pull --rebase
confirm "Push ?"
verbose
for r in ${REMOTES[*]}; do
git push -n $r 2.5
done
git tag -s $VERSION -m $VERSION
git describe
if [ -n "$(git status --porcelain)" ]; then
git status -s
confirm "Clean git repository ?"
git clean -f
fi
make tarball
unverbose
}
push_tags() {
confirm "Push tag ?"
verbose
for r in ${REMOTES[*]}; do
git push $r --tags -n
done
for r in ${REMOTES[*]}; do
git push $r --tags
done
unverbose
}
drop_tags() {
confirm "Drop tag $VERSION ?"
verbose
for r in ${REMOTES[*]}; do
git push $r --delete $VERSION || true
done
git tag -d $VERSION
unverbose
}
push_ftp() {
confirm "Push to ftpmaster@oar ?"
verbose
scp ../tarballs/oar-${VERSION}.tar.gz $OARFTP:oar-ftp.imag.fr/oar/sources/testing/
ssh $OARFTP \
"cd oar-ftp.imag.fr/oar/sources/testing/ && md5sum oar-$VERSION.tar.gz > oar-$VERSION.tar.gz.md5sum && sha1sum oar-$VERSION.tar.gz > oar-$VERSION.tar.gz.sha1sum"
if [ -n "$STABLE" ]; then
ssh $OARFTP \
"cd oar-ftp.imag.fr/oar/sources/stable/ && for f in oar-$VERSION.tar.gz oar-$VERSION.tar.gz.md5sum oar-$VERSION.tar.gz.sha1sum; do ln -s ../testing/\$f . ; done"
fi
unverbose
}
OARFTP=ftpmaster@oar-ftp.lig
declare -a REMOTES
getopt() {
unset OPTIND
while getopts "r:V:f:Sv" OPT; do
case $OPT in
r)
REMOTES+=($OPTARG)
;;
S)
STABLE=1
;;
V)
VERSION=$OPTARG
;;
v)
VERBOSE=1
;;
f)
OARFTP=$OPTARG
;;
*)
usage;
;;
esac
done
}
getopt "$@"
shift $((OPTIND - 1))
ACTION=$1
shift
getopt "$@"
if [ -z "${REMOTES[*]}" ]; then
REMOTES=("github" "origin")
fi
case $ACTION in
release)
release
;;
push-tags)
push_tags
;;
push-ftp)
push_ftp
;;
drop-tags)
drop_tags
;;
all)
release
push_tags
push_ftp
;;
*)
usage;
;;
esac
|