Debian Codegraph @

misc/make_release

raw
1 #!/bin/bash -e
2 # Tarball release script. See http://oar.imag.fr/wiki:tarball_release
3
4 confirm() {
5 read -n 1 -s -p "$1 " ANSWER
6 echo
7 if [ "$ANSWER" != "y" -a "$ANSWER" != "Y" ]; then
8 echo "Aborted!"
9 exit 1
10 fi
11 }
12
13 usage() {
14 cat <<EOF
15 $0 [<OPTIONS>] <ACTION>
16 Actions:
17 release
18 push-tags
19 push-ftp
20 drop-tags
21 all
22
23 Options:
24 -S This is a stable release
25 -V <version> Gives the version of the release
26 -r Gives git remote (multiple possible)
27 -v Verbose
28 -f <hostname> Gives the OAR FTP hostname for ssh
29 EOF
30 }
31
32 verbose() {
33 if [ -n "$VERBOSE" ]; then
34 set -x
35 fi
36 }
37
38 unverbose() {
39 set +x
40 }
41
42 release() {
43 if [ -z "$VERSION" ]; then
44 read -p "Version ? " VERSION
45 fi
46 confirm "Release tarball for OAR version $VERSION ?"
47 git pull --rebase
48 confirm "Push ?"
49 verbose
50 for r in ${REMOTES[*]}; do
51 git push -n $r 2.5
52 done
53 git tag -s $VERSION -m $VERSION
54 git describe
55 if [ -n "$(git status --porcelain)" ]; then
56 git status -s
57 confirm "Clean git repository ?"
58 git clean -f
59 fi
60 make tarball
61 unverbose
62 }
63
64 push_tags() {
65 confirm "Push tag ?"
66 verbose
67 for r in ${REMOTES[*]}; do
68 git push $r --tags -n
69 done
70 for r in ${REMOTES[*]}; do
71 git push $r --tags
72 done
73 unverbose
74 }
75
76 drop_tags() {
77 confirm "Drop tag $VERSION ?"
78 verbose
79 for r in ${REMOTES[*]}; do
80 git push $r --delete $VERSION || true
81 done
82 git tag -d $VERSION
83 unverbose
84 }
85
86 push_ftp() {
87 confirm "Push to ftpmaster@oar ?"
88 verbose
89 scp ../tarballs/oar-${VERSION}.tar.gz $OARFTP:oar-ftp.imag.fr/oar/sources/testing/
90 ssh $OARFTP \
91 "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"
92
93 if [ -n "$STABLE" ]; then
94 ssh $OARFTP \
95 "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"
96 fi
97 unverbose
98 }
99
100 [email protected]
101 declare -a REMOTES
102 getopt() {
103 unset OPTIND
104 while getopts "r:V:f:Sv" OPT; do
105 case $OPT in
106 r)
107 REMOTES+=($OPTARG)
108 ;;
109 S)
110 STABLE=1
111 ;;
112 V)
113 VERSION=$OPTARG
114 ;;
115 v)
116 VERBOSE=1
117 ;;
118 f)
119 OARFTP=$OPTARG
120 ;;
121 *)
122 usage;
123 ;;
124 esac
125 done
126 }
127
128 getopt "$@"
129 shift $((OPTIND - 1))
130 ACTION=$1
131 shift
132 getopt "$@"
133
134 if [ -z "${REMOTES[*]}" ]; then
135 REMOTES=("github" "origin")
136 fi
137
138 case $ACTION in
139 release)
140 release
141 ;;
142 push-tags)
143 push_tags
144 ;;
145 push-ftp)
146 push_ftp
147 ;;
148 drop-tags)
149 drop_tags
150 ;;
151 all)
152 release
153 push_tags
154 push_ftp
155 ;;
156 *)
157 usage;
158 ;;
159 esac