release.sh 3.04 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 26 27 28 29 30
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

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

anarcat's avatar
anarcat committed
31
Usage: $0 <new_version> [<old_version>]
anarcat's avatar
anarcat committed
32 33 34 35 36 37 38 39 40 41 42 43 44
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
45
release $version.
anarcat's avatar
anarcat committed
46 47 48 49 50 51
EOF

cat <<EOF

The following operations will be done:
 1. change the makefile to download tarball
52 53 54 55 56 57
 2. change the upgrade.sh.txt version
 3. display the resulting diff
 4. commit those changes to git
 5. lay down the tag (prompting you for a changelog)
 6. revert the commit
 7. (optionally) push those changes
anarcat's avatar
anarcat committed
58

anarcat's avatar
anarcat committed
59
The operation can be aborted before step 7. Don't forget that as
anarcat's avatar
anarcat committed
60 61 62 63 64 65 66 67 68 69 70
long as changes are not pushed upstream, this can all be reverted (see
git-reset(1) and git-revert(1) ).

EOF

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

git pull
echo changing makefile to download tarball
71 72 73 74
#sed -i'.tmp' -e'/^projects\[hostmaster\]\[download\]\[type\]/s/=.*$/ = "get"/' \
#  -e'/^projects\[hostmaster\]\[download\]\[url\]/s#=.*$#= "http://ftp.drupal.org/files/projects/hostmaster-'$version'.tgz"#' \
#  -e'/^projects\[hostmaster\]\[download\]\[branch\].*/s/\[branch\] *=.*$/[directory_name] = "hostmaster"/' aegir.make && git add aegir.make && rm aegir.make.tmp
sed -i'.tmp' -e'/^projects\[hostmaster\]\[download\]\[type\]/s/=.*$/= "git"/' \
75
  -e'/^projects\[hostmaster\]\[download\]\[url\]/s#=.*$#= "http://git.drupal.org/project/hostmaster.git"#' \
76
  -e'/^projects\[hostmaster\]\[download\]\[branch\].*/s/\[branch\] *=.*$/[tag] = "'$version'"/' aegir.make && git add aegir.make && rm aegir.make.tmp
anarcat's avatar
anarcat committed
77

78
echo changing provision.info version
anarcat's avatar
anarcat committed
79
sed -i'.tmp' -e"s/version *=.*$/version=$version/" provision.info
80
git add provision.info && rm provision.info.tmp
81

82 83 84
echo changing upgrade.sh.txt version
sed -i'.tmp' -e"s/AEGIR_VERSION=.*$/AEGIR_VERSION=\"$version\"/" upgrade.sh.txt && git add upgrade.sh.txt && rm upgrade.sh.txt.tmp

anarcat's avatar
anarcat committed
85 86 87 88 89 90 91
echo resulting changes to be committed:
git diff --cached | cat

if prompt_yes_no "commit changes and tag release? (y/N) "; then
    echo okay, committing...
else
    echo 'aborting, leaving changes in git staging area'
anarcat's avatar
anarcat committed
92
    echo 'use "git reset --hard" to revert the index'
anarcat's avatar
anarcat committed
93 94 95
    exit 1
fi

96
commitmsg=`git commit -m"change version information for release $version"`
anarcat's avatar
anarcat committed
97
echo $commitmsg
98 99
commitid=`echo $commitmsg | sed 's/^\[[^ ]* \([a-z0-9]*\)\].*$/\1/'`
git tag -a $version
anarcat's avatar
anarcat committed
100 101 102 103 104 105 106 107

echo reverting tree to HEAD versions
git revert $commitid

if prompt_yes_no "push tags and commits upstream? (y/N) "; then
    # this makes sure we push the commit *and* the tag
    git push --tags origin HEAD
fi