Commit | Line | Data |
---|---|---|
60a40431 | 1 | #!/bin/bash |
f0711d23 | 2 | set -e |
60a40431 TO |
3 | |
4 | confdir=$(dirname $0) | |
5 | start_point="$1" | |
6 | version="$2" | |
59a39a3b | 7 | first_act="$3" |
d58ceeb3 | 8 | distmaker_tgt=all |
60a40431 TO |
9 | |
10 | if [ ! -f "$confdir/releaser.conf" ]; then | |
11 | echo | |
12 | echo "Missing configuration file. Please copy $confdir/releaser.conf.txt to $confdir/releaser.conf and edit it." | |
13 | exit 1 | |
14 | fi | |
15 | source "$confdir/releaser.conf" | |
16 | ||
59a39a3b | 17 | if [ -z "$start_point" -o -z "$version" -o -z "$first_act" ]; then |
60a40431 | 18 | echo |
59a39a3b TO |
19 | echo "Usage:" |
20 | echo " $0 <start_point> <version> --build" | |
21 | echo " $0 <start_point> <version> --publish" | |
481babac | 22 | echo " $0 <start_point> <version> --update" |
59a39a3b | 23 | echo " $0 <start_point> <version> --clean" |
481babac | 24 | echo " $0 <start_point> <version> --build --publish --update --clean [[ORDER SIGNIFICANT]]" |
59a39a3b | 25 | echo "Arguments:" |
60a40431 | 26 | echo " <start_point> is a branch name (e.g. \"master\")" |
8fb8f4de | 27 | echo " <version> is Civi release (e.g. \"4.3.beta2\"); it will become a tag name" |
60a40431 TO |
28 | exit 2 |
29 | fi | |
30 | ||
31 | if [ "`echo -n $version | tr -d 0-9.`" = '' ]; then | |
32 | is_stable=1 | |
33 | else | |
34 | is_stable= | |
35 | fi | |
36 | ||
37 | ################################################# | |
38 | ## Git setup | |
39 | function do_git_config() { | |
40 | git config --global user.name "$git_author_name" | |
41 | git config --global user.email "$git_author_email" | |
42 | } | |
43 | ||
44 | ################################################# | |
45 | ## Create build directories; checkout repos | |
46 | function do_mk_project() { | |
47 | for dir in \ | |
48 | "$workdir" \ | |
49 | "$workdir/$version" \ | |
50 | "$workdir/$version/export" \ | |
51 | "$workdir/$version/gen" \ | |
52 | "$workdir/$version/tarballs" \ | |
53 | "$workdir/$version/tmp" | |
54 | do | |
55 | if [ ! -d "$dir" ]; then | |
56 | mkdir -p "$dir" | |
57 | fi | |
58 | done | |
59 | ||
1d2d6ae8 | 60 | $cmd_gitify all "$git_base_url" "$workdir/$version/export" --l10n --branch "$start_point" --skip-gencode |
60a40431 TO |
61 | } |
62 | ||
63 | ################################################# | |
64 | ## Tag all repos | |
65 | function do_git_tag() { | |
66 | cd $workdir/$version | |
67 | for dir in export export/joomla export/WordPress export/packages ; do | |
68 | pushd $dir | |
69 | git checkout "$start_point" | |
70 | git tag "$version" | |
71 | popd | |
72 | done | |
73 | ||
74 | for drupal_ver in 6.x 7.x ; do | |
75 | pushd export/drupal | |
76 | git checkout "${drupal_ver}-${start_point}" | |
77 | git tag "${drupal_ver}-${version}" | |
78 | popd | |
79 | done | |
80 | } | |
81 | ||
82 | ################################################# | |
83 | ## Publish tags via git | |
84 | function do_git_tag_push() { | |
85 | cd $workdir/$version | |
86 | for dir in export export/joomla export/WordPress export/packages ; do | |
87 | pushd $dir | |
88 | git push -f origin "$version" | |
89 | popd | |
90 | done | |
91 | ||
92 | for drupal_ver in 6.x 7.x ; do | |
93 | pushd export/drupal | |
94 | git push -f origin "${drupal_ver}-${version}" | |
95 | popd | |
96 | done | |
97 | } | |
98 | ||
99 | ################################################# | |
100 | ## Build | |
101 | function do_distmaker() { | |
102 | cd $workdir/$version | |
103 | ||
104 | ## Determine SCM revision of main codebase | |
105 | pushd "export" | |
106 | rev=$(git rev-parse HEAD | head -c10) | |
107 | popd | |
108 | ||
109 | # create the distmaker.conf file | |
110 | echo " | |
111 | DM_SOURCEDIR=$workdir/$version/export | |
112 | DM_GENFILESDIR=$workdir/$version/gen | |
113 | DM_TMPDIR=$workdir/$version/tmp | |
114 | DM_TARGETDIR=$workdir/$version/tarballs | |
115 | DM_PHP=$cmd_php | |
116 | DM_RSYNC=$cmd_rsync | |
117 | DM_VERSION=$version | |
118 | DM_REVISION=$rev | |
119 | DM_ZIP=$cmd_zip | |
665d689d TO |
120 | DM_REF_CORE=${start_point} |
121 | DM_REF_DRUPAL=7.x-${start_point} | |
122 | DM_REF_DRUPAL6=6.x-${start_point} | |
123 | DM_REF_JOOMLA=${start_point} | |
124 | DM_REF_WORDPRESS=${start_point} | |
125 | DM_REF_PACKAGES=${start_point} | |
60a40431 TO |
126 | " > $workdir/$version/export/distmaker/distmaker.conf |
127 | ||
128 | # create a minimal civicrm.settings.php file | |
129 | mkdir -p $workdir/$version/export/default | |
130 | echo "<?php define('CIVICRM_GETTEXT_RESOURCEDIR', '$workdir/$version/export/l10n/'); define('CIVICRM_UF', 'Drupal'); global \$civicrm_root; \$civicrm_root = '$workdir/$version/export'; ?>" > $workdir/$version/export/default/civicrm.settings.php | |
131 | ||
132 | # create a minimal settings_location.php file | |
133 | echo "<?php define('CIVICRM_CONFDIR', '$workdir/$version/export'); ?>" > $workdir/$version/export/settings_location.php | |
134 | ||
135 | # run the exported distmaker | |
136 | cd $workdir/$version/export/distmaker | |
d58ceeb3 | 137 | ./distmaker.sh $distmaker_tgt > $workdir/$version/build.log |
60a40431 TO |
138 | } |
139 | ||
140 | ################################################# | |
141 | ## Publish files | |
142 | function do_publish() { | |
143 | # publish to sf.net | |
144 | cd $workdir/$version/tarballs | |
145 | ||
d7d26e9c | 146 | $cmd_md5sum *.tar.gz *.tgz *.zip > civicrm-$version.MD5SUMS |
719d9691 | 147 | echo $gpg_pass | $cmd_gpg --armor --batch --passphrase-fd 0 --sign civicrm-$version.MD5SUMS |
60a40431 TO |
148 | |
149 | if [ "$is_stable" ]; then | |
150 | echo mkdir ${publish_stable_dir}/$version | $cmd_sftp ${publish_ssh} | |
151 | $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_stable_dir}/$version | |
152 | else | |
153 | echo mkdir ${publish_latest_dir}/$version | $cmd_sftp ${publish_ssh} | |
154 | $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_latest_dir}/$version | |
155 | fi | |
156 | ||
d7d26e9c | 157 | mv *.tar.gz *.tgz *.zip *MD5SUMS* $build_dest |
60a40431 TO |
158 | |
159 | # publish to latest.civicrm.org | |
160 | # FIXME: isn't this racy when doing concurrent security releases | |
161 | if [ "$is_stable" ]; then | |
162 | echo $version > $latest/stable.txt | |
163 | fi | |
164 | echo $version > $latest/latest.txt | |
165 | } | |
166 | ||
481babac CW |
167 | ################################################# |
168 | ## Update Version Info | |
169 | function do_update() { | |
44fa8c11 | 170 | echo "VERSION UPDATE: Enter the version that comes after $version (or enter nothing to abort)" |
ba9b059f CW |
171 | read new_ver |
172 | if [ -n "$new_ver" ]; then | |
173 | cd $workdir/$version/export | |
6493e9b0 CW |
174 | # create sql upgrade file |
175 | tpl="CRM/Upgrade/Incremental/sql/$new_ver.mysql.tpl" | |
12d98f6c CW |
176 | if [ ! -f $tpl ]; then |
177 | echo "{* file to handle db changes in $new_ver during upgrade *}" > $tpl | |
6493e9b0 | 178 | fi |
44fa8c11 CW |
179 | # escape regex special chars |
180 | arg=`echo "$version" | sed 's:[]\[\^\$\.\*\/]:\\\\&:g'` | |
ba9b059f | 181 | for file in xml/version.xml sql/civicrm_generated.mysql; do |
44fa8c11 CW |
182 | set -ex |
183 | git checkout $file | |
184 | sed "s/$arg/$new_ver/" < $file > $file.tmp | |
ba9b059f | 185 | mv $file.tmp $file |
44fa8c11 | 186 | set +x |
ba9b059f | 187 | done |
44fa8c11 CW |
188 | # print the diff directly to the screen |
189 | git diff | cat | |
190 | echo "Push these changes? y/n" | |
191 | read input | |
192 | if [ "$input" = "y" ]; then | |
193 | set -ex | |
6493e9b0 | 194 | git add xml/version.xml sql/civicrm_generated.mysql $tpl |
44fa8c11 CW |
195 | git commit -m "Update version to $new_ver" |
196 | git push origin "$start_point" | |
197 | set +x | |
198 | else | |
199 | do_update | |
200 | fi | |
ba9b059f CW |
201 | else |
202 | echo "No version entered. Aborting version update." | |
203 | fi | |
481babac CW |
204 | } |
205 | ||
60a40431 TO |
206 | ################################################# |
207 | ## Cleanup | |
208 | function do_cleanup() { | |
209 | cd $workdir/$version | |
210 | rm -rf export gen tmp tarballs tmp | |
211 | } | |
212 | ||
213 | ################################################# | |
214 | ## Main | |
215 | ||
216 | ## Refactoring note: this used to be one monolithic script | |
217 | ||
59a39a3b TO |
218 | shift ## start point |
219 | shift ## version | |
220 | for ACT in "$@" ; do | |
221 | case "$ACT" in | |
222 | --build) | |
223 | set -ex | |
224 | do_git_config | |
225 | do_mk_project | |
226 | do_git_tag | |
227 | do_distmaker | |
228 | set +x | |
229 | ;; | |
230 | --publish) | |
231 | set -ex | |
232 | do_git_tag_push | |
233 | do_publish | |
234 | set +x | |
235 | ;; | |
481babac | 236 | --update) |
481babac | 237 | set +x |
44fa8c11 | 238 | do_update |
481babac | 239 | ;; |
59a39a3b TO |
240 | --clean) |
241 | set -ex | |
242 | do_cleanup | |
243 | set +x | |
244 | ;; | |
245 | *) | |
246 | echo "unrecognized: $ACT" | |
247 | ;; | |
248 | esac | |
249 | done | |
250 |