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" | |
d58ceeb3 | 7 | distmaker_tgt=all |
60a40431 TO |
8 | |
9 | if [ ! -f "$confdir/releaser.conf" ]; then | |
10 | echo | |
11 | echo "Missing configuration file. Please copy $confdir/releaser.conf.txt to $confdir/releaser.conf and edit it." | |
12 | exit 1 | |
13 | fi | |
14 | source "$confdir/releaser.conf" | |
15 | ||
16 | if [ -z "$version" -o -z "$start_point" ]; then | |
17 | echo | |
18 | echo "Usage: $0 <start_point> <version>" | |
19 | echo " <start_point> is a branch name (e.g. \"master\")" | |
8fb8f4de | 20 | echo " <version> is Civi release (e.g. \"4.3.beta2\"); it will become a tag name" |
60a40431 TO |
21 | exit 2 |
22 | fi | |
23 | ||
24 | if [ "`echo -n $version | tr -d 0-9.`" = '' ]; then | |
25 | is_stable=1 | |
26 | else | |
27 | is_stable= | |
28 | fi | |
29 | ||
f0711d23 TO |
30 | set -ex |
31 | ||
60a40431 TO |
32 | ################################################# |
33 | ## Git setup | |
34 | function do_git_config() { | |
35 | git config --global user.name "$git_author_name" | |
36 | git config --global user.email "$git_author_email" | |
37 | } | |
38 | ||
39 | ################################################# | |
40 | ## Create build directories; checkout repos | |
41 | function do_mk_project() { | |
42 | for dir in \ | |
43 | "$workdir" \ | |
44 | "$workdir/$version" \ | |
45 | "$workdir/$version/export" \ | |
46 | "$workdir/$version/gen" \ | |
47 | "$workdir/$version/tarballs" \ | |
48 | "$workdir/$version/tmp" | |
49 | do | |
50 | if [ ! -d "$dir" ]; then | |
51 | mkdir -p "$dir" | |
52 | fi | |
53 | done | |
54 | ||
55 | $cmd_gitify all "$git_base_url" "$workdir/$version/export" --l10n | |
56 | } | |
57 | ||
58 | ################################################# | |
59 | ## Tag all repos | |
60 | function do_git_tag() { | |
61 | cd $workdir/$version | |
62 | for dir in export export/joomla export/WordPress export/packages ; do | |
63 | pushd $dir | |
64 | git checkout "$start_point" | |
65 | git tag "$version" | |
66 | popd | |
67 | done | |
68 | ||
69 | for drupal_ver in 6.x 7.x ; do | |
70 | pushd export/drupal | |
71 | git checkout "${drupal_ver}-${start_point}" | |
72 | git tag "${drupal_ver}-${version}" | |
73 | popd | |
74 | done | |
75 | } | |
76 | ||
77 | ################################################# | |
78 | ## Publish tags via git | |
79 | function do_git_tag_push() { | |
80 | cd $workdir/$version | |
81 | for dir in export export/joomla export/WordPress export/packages ; do | |
82 | pushd $dir | |
83 | git push -f origin "$version" | |
84 | popd | |
85 | done | |
86 | ||
87 | for drupal_ver in 6.x 7.x ; do | |
88 | pushd export/drupal | |
89 | git push -f origin "${drupal_ver}-${version}" | |
90 | popd | |
91 | done | |
92 | } | |
93 | ||
94 | ################################################# | |
95 | ## Build | |
96 | function do_distmaker() { | |
97 | cd $workdir/$version | |
98 | ||
99 | ## Determine SCM revision of main codebase | |
100 | pushd "export" | |
101 | rev=$(git rev-parse HEAD | head -c10) | |
102 | popd | |
103 | ||
104 | # create the distmaker.conf file | |
105 | echo " | |
106 | DM_SOURCEDIR=$workdir/$version/export | |
107 | DM_GENFILESDIR=$workdir/$version/gen | |
108 | DM_TMPDIR=$workdir/$version/tmp | |
109 | DM_TARGETDIR=$workdir/$version/tarballs | |
110 | DM_PHP=$cmd_php | |
111 | DM_RSYNC=$cmd_rsync | |
112 | DM_VERSION=$version | |
113 | DM_REVISION=$rev | |
114 | DM_ZIP=$cmd_zip | |
115 | " > $workdir/$version/export/distmaker/distmaker.conf | |
116 | ||
117 | # create a minimal civicrm.settings.php file | |
118 | mkdir -p $workdir/$version/export/default | |
119 | 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 | |
120 | ||
121 | # create a minimal settings_location.php file | |
122 | echo "<?php define('CIVICRM_CONFDIR', '$workdir/$version/export'); ?>" > $workdir/$version/export/settings_location.php | |
123 | ||
124 | # run the exported distmaker | |
125 | cd $workdir/$version/export/distmaker | |
d58ceeb3 | 126 | ./distmaker.sh $distmaker_tgt > $workdir/$version/build.log |
60a40431 TO |
127 | } |
128 | ||
129 | ################################################# | |
130 | ## Publish files | |
131 | function do_publish() { | |
132 | # publish to sf.net | |
133 | cd $workdir/$version/tarballs | |
134 | ||
d7d26e9c | 135 | $cmd_md5sum *.tar.gz *.tgz *.zip > civicrm-$version.MD5SUMS |
719d9691 | 136 | echo $gpg_pass | $cmd_gpg --armor --batch --passphrase-fd 0 --sign civicrm-$version.MD5SUMS |
60a40431 TO |
137 | |
138 | if [ "$is_stable" ]; then | |
139 | echo mkdir ${publish_stable_dir}/$version | $cmd_sftp ${publish_ssh} | |
140 | $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_stable_dir}/$version | |
141 | else | |
142 | echo mkdir ${publish_latest_dir}/$version | $cmd_sftp ${publish_ssh} | |
143 | $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_latest_dir}/$version | |
144 | fi | |
145 | ||
d7d26e9c | 146 | mv *.tar.gz *.tgz *.zip *MD5SUMS* $build_dest |
60a40431 TO |
147 | |
148 | # publish to latest.civicrm.org | |
149 | # FIXME: isn't this racy when doing concurrent security releases | |
150 | if [ "$is_stable" ]; then | |
151 | echo $version > $latest/stable.txt | |
152 | fi | |
153 | echo $version > $latest/latest.txt | |
154 | } | |
155 | ||
156 | ################################################# | |
157 | ## Cleanup | |
158 | function do_cleanup() { | |
159 | cd $workdir/$version | |
160 | rm -rf export gen tmp tarballs tmp | |
161 | } | |
162 | ||
163 | ################################################# | |
164 | ## Main | |
165 | ||
166 | ## Refactoring note: this used to be one monolithic script | |
167 | ||
168 | do_git_config | |
169 | do_mk_project | |
170 | do_git_tag | |
171 | do_distmaker | |
172 | do_git_tag_push | |
173 | do_publish | |
174 | do_cleanup |