release.sh 3.38 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="6.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> [<old_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
anarcat's avatar
anarcat committed
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 59
 6. revert the commit
 7. (optionally) push those changes
anarcat's avatar
anarcat committed
60

61
The operation can be aborted before step 7. Don't forget that as
anarcat's avatar
anarcat committed
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

anarcat's avatar
anarcat committed
71 72
git pull --rebase

73 74 75
dch -v $version -D testing
git add debian/changelog

anarcat's avatar
anarcat committed
76
echo changing makefile to download tarball
77
#sed -i'.tmp' -e'/^projects\[hostmaster\]\[download\]\[type\]/s/=.*$/ = "get"/' \
78
#  -e'/^projects\[hostmaster\]\[download\]\[url\]/s#=.*$#= "http://ftp.drupal.org/files/projects/hostmaster-'$major-$version'.tgz"#' \
79 80
#  -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"/' \
81
  -e'/^projects\[hostmaster\]\[download\]\[url\]/s#=.*$#= "http://git.drupal.org/project/hostmaster.git"#' \
82
  -e'/^projects\[hostmaster\]\[download\]\[branch\].*/s/\[branch\] *=.*$/[tag] = "'$major-$version'"/' aegir.make && git add aegir.make && rm aegir.make.tmp
anarcat's avatar
anarcat committed
83

84
echo changing provision.info version
85
sed -i'.tmp' -e"s/version *=.*$/version=$major-$version/" provision.info
86
git add provision.info && rm provision.info.tmp
87

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

anarcat's avatar
anarcat committed
91 92 93 94 95 96 97
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
98
    echo 'use "git reset --hard" to revert the index'
anarcat's avatar
anarcat committed
99 100 101
    exit 1
fi

102
commitmsg=`git commit -m"change version information for release $version"`
anarcat's avatar
anarcat committed
103
echo $commitmsg
104
commitid=`echo $commitmsg | sed 's/^\[[^ ]* \([a-z0-9]*\)\].*$/\1/'`
105
sed -n '1,/ --/p' debian/changelog | git tag -a -F - $major-$version
anarcat's avatar
anarcat committed
106 107

echo reverting tree to HEAD versions
108 109 110 111 112 113
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

anarcat's avatar
anarcat committed
114 115 116 117 118

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