release.sh 5.73 KB
Newer Older
anarcat's avatar
anarcat committed
1 2
#!/bin/sh -e

3
# simple prompt
anarcat's avatar
anarcat committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
prompt_yes_no() {
  while true ; do
    printf "$* [Y/n] "
    read answer
    if [ -z "$answer" ] ; then
      return 0
    fi
    case $answer in
      [Yy]|[Yy][Ee][Ss])
        return 0
        ;;
      [Nn]|[Nn][Oo])
        return 1
        ;;
      *)
        echo "Please answer yes or no"
        ;;
    esac
 done 
}

version=$1
26
major="7.x"
anarcat's avatar
anarcat committed
27 28 29 30 31

if [ $# -lt 1 -o "$version" = "-h" ]; then
    cat <<EOF 
not enough arguments

anarcat's avatar
anarcat committed
32
Usage: $0 <new_version>
anarcat's avatar
anarcat committed
33 34 35 36 37 38 39 40 41 42 43 44 45
EOF
    exit 1
fi

cat <<EOF
Aegir release script
====================

This script should only be used by the core dev team when doing an
official release. If you are not one of those people, you probably
shouldn't be running this.

This script is going to modify the configs and documentation to
46
release $major-$version.
anarcat's avatar
anarcat committed
47 48 49 50 51
EOF

cat <<EOF

The following operations will be done:
52
 0. prompt you for a debian/changelog entry
53
 1. change the makefile to download tarball
54 55 56
 2. change the upgrade.sh.txt version
 3. display the resulting diff
 4. commit those changes to git
57
 5. lay down the tag
58
 6. revert the commit
59 60
 7. clone fresh copies of hosting/hostmaster and eldir to lay down the tag
 8. (optionally) push those changes
helmo's avatar
helmo committed
61 62
 9. clone fresh copies of golden contrib to lay down the tag
10. (optionally) push those changes
anarcat's avatar
anarcat committed
63

helmo's avatar
helmo committed
64 65
 ARE YOU SURE you disabled the D_aegir-debian-build-3x job in Jenkins?

66
The operation can be aborted before step 8. Don't forget that as
67 68
long as changes are not pushed upstream, this can all be reverted (see
git-reset(1) and git-revert(1) ).
anarcat's avatar
anarcat committed
69 70 71 72 73 74 75

EOF

if ! prompt_yes_no "continue?" ; then
    exit 1
fi

anarcat's avatar
anarcat committed
76 77
git pull --rebase

78 79
debversion=$(echo $version | sed -e 's/-/~/')
dch -v $debversion -D unstable
80 81
git add debian/changelog

82
echo changing hostmaster version in aegir-release.make
83
sed -i'.tmp' -e '/^projects\[hostmaster\]\[version\]/s/=.*$/= "'"$version"'"/' aegir-release.make && git add aegir-release.make && rm aegir-release.make.tmp
84 85 86

echo enabling release makefilexs
ln -sf aegir-release.make aegir.make && git add aegir.make
anarcat's avatar
anarcat committed
87

88
echo changing provision.info version
89
sed -i'.tmp' -e"s/version *=.*$/version=$major-$version/" provision.info
90
git add provision.info && rm provision.info.tmp
91

92
echo changing upgrade.sh.txt version
93
sed -i'.tmp' -e"s/AEGIR_VERSION=.*$/AEGIR_VERSION=\"$major-$version\"/" upgrade.sh.txt && git add upgrade.sh.txt && rm upgrade.sh.txt.tmp
94

anarcat's avatar
anarcat committed
95 96 97
echo resulting changes to be committed:
git diff --cached | cat

anarcat's avatar
anarcat committed
98
if prompt_yes_no "commit changes and tag release?"; then
anarcat's avatar
anarcat committed
99 100 101
    echo okay, committing...
else
    echo 'aborting, leaving changes in git staging area'
anarcat's avatar
anarcat committed
102
    echo 'use "git reset --hard" to revert the index'
anarcat's avatar
anarcat committed
103 104 105
    exit 1
fi

106 107
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
NEW_TAG="$major-$version"
108
commitmsg=`git commit -m"change version information for release $version"`
anarcat's avatar
anarcat committed
109
echo $commitmsg
110
commitid=`echo $commitmsg | sed 's/^\[[^ ]* \([a-z0-9]*\)\].*$/\1/'`
111
sed -n '1,/ --/p' debian/changelog | git tag -a -F - $major-$version
anarcat's avatar
anarcat committed
112 113

echo reverting tree to HEAD versions
114 115 116 117 118 119
git revert --no-commit $commitid
# Unstage the debian/changelog change, as we don't want to revert that.
git reset --quiet HEAD 'debian/changelog'
git checkout -- 'debian/changelog'
git commit

120 121 122 123 124 125 126 127

echo "Work on the other project repositories."
mkdir -p build-area;

# Hostmaster
rm -rf build-area/hostmaster
git clone --branch $CURRENT_BRANCH `git config remote.origin.url | sed 's/provision/hostmaster/'` build-area/hostmaster

128 129 130 131 132 133 134
cd build-area/hostmaster
echo changing hostmaster.make versions
ln -sf drupal-org.make hostmaster.make && git add hostmaster.make
cd -

git --work-tree=build-area/hostmaster --git-dir=build-area/hostmaster/.git commit -m"change version information for release $version"

135 136 137
echo "Setting the tag $NEW_TAG in a clean hostmaster clone."
git --work-tree=build-area/hostmaster --git-dir=build-area/hostmaster/.git tag -a $NEW_TAG -m 'Add a new release tag.'

138 139 140 141
echo reverting tree to HEAD versions
git revert HEAD^


142 143 144 145 146 147 148 149 150 151 152
# Hosting
rm -rf build-area/hosting
git clone --branch $CURRENT_BRANCH `git config remote.origin.url | sed 's/provision/hosting/'` build-area/hosting

echo "Setting the tag $NEW_TAG in a clean hosting clone."
git --work-tree=build-area/hosting --git-dir=build-area/hosting/.git tag -a $NEW_TAG -m 'Add a new release tag.'

# Eldir
rm -rf build-area/eldir
git clone --branch $CURRENT_BRANCH `git config remote.origin.url | sed 's/provision/eldir/'` build-area/eldir

153 154
echo "Setting the tag $NEW_TAG in a clean eldir clone."
git --work-tree=build-area/eldir --git-dir=build-area/eldir/.git tag -a $NEW_TAG -m 'Add a new release tag.'
155

helmo's avatar
helmo committed
156 157
echo =========
echo
158
# Can we push?
helmo's avatar
helmo committed
159
if prompt_yes_no "Push tags and commits upstream? "; then
160 161
    # this makes sure we push the commit *and* the tag
    git push --tags origin HEAD
162 163
    git --work-tree=build-area/hostmaster --git-dir=build-area/hostmaster/.git push --tags origin HEAD
    git --work-tree=build-area/hosting --git-dir=build-area/hosting/.git push --tags origin HEAD
164
    git --work-tree=build-area/eldir --git-dir=build-area/eldir/.git push --tags origin HEAD
165
fi
166 167 168 169 170 171 172


# Golden Contrib

golden_contribs="hosting_civicrm hosting_git hosting_remote_import hosting_site_backup_manager hosting_tasks_extra"
for shortname in $golden_contribs; do
  rm -rf build-area/$shortname
173
  git clone --branch $CURRENT_BRANCH `git config remote.origin.url | sed "s/provision/$shortname/"` build-area/$shortname
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189

  echo "Setting the tag $NEW_TAG in a clean $shortname clone."
  git --work-tree=build-area/$shortname --git-dir=build-area/$shortname/.git tag -a $NEW_TAG -m 'Add a new release tag.'

done

echo =========
echo
echo Golden Contribs: $golden_contribs
echo
# Can we push?
if prompt_yes_no "Push tags and commits for GOLDEN CONTRIB upstream? "; then
  for shortname in $golden_contribs; do
    git --work-tree=build-area/$shortname --git-dir=build-area/$shortname/.git push --tags origin HEAD
  done
fi