release.sh 2.95 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>
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
 7. (optionally) push those changes
anarcat's avatar
anarcat committed
60

61 62 63
The operation can be aborted before step 7. Don't forget that as
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
64 65 66 67 68 69 70

EOF

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

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

73 74
debversion=$(echo $version | sed -e 's/-/~/')
dch -v $debversion -D unstable
75 76
git add debian/changelog

77
echo changing hostmaster version in aegir-release.make
anarcat's avatar
anarcat committed
78
sed -i'.tmp' -e '/^projects\[hostmaster\]\[version\]/s/=.*$/= "'"$major-$version"'"/' aegir-release.make && git add aegir-release.make && rm aegir-release.make.tmp
79 80 81

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

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

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

anarcat's avatar
anarcat committed
90 91 92
echo resulting changes to be committed:
git diff --cached | cat

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

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

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

113 114 115 116
if prompt_yes_no "push tags and commits upstream? "; then
    # this makes sure we push the commit *and* the tag
    git push --tags origin HEAD
fi