Commit c47ae227 authored by Richard Mansfield's avatar Richard Mansfield

Add script to combine first steps of release process. Still needs work, mainly error checking.

parent e66af2a4
#!/bin/bash
#
# Builds release tarballs of Mahara at the given version, ready for
# distribution
set -e
print_usage() {
echo "Usage is $0 [version] [branch]"
echo "e.g. $0 0.6.2 0.6_STABLE"
echo "e.g. $0 1.0.0alpha1 master"
}
if [ -z "$1" ] || [ -z "$2" ]; then
print_usage
exit 1
fi
MAJOR=${1%.*}
REST=${1##*.}
MINOR=${REST%%[a-z]*}
MICRO=`echo ${REST} | sed 's/^[0-9]*//g'`
MICROA=`echo ${MICRO} | sed 's/[^a-z]//g'`
MICROB=`echo ${MICRO} | sed 's/[a-z]//g'`
BRANCH=$2
OPTION=$3
#BUILDDIR="/tmp/mahara/tarballs"
BUILDDIR="/home/richard/foobar44/mahara/tarballs"
CURRENTDIR="`pwd`"
if [ -z "${MAJOR}" ] || [ -z "${MINOR}" ]; then
print_usage
exit 1
fi
if [ -d ${BUILDDIR} ]; then
rm -rf ${BUILDDIR}
fi
mkdir -p ${BUILDDIR}/mahara
pushd ${BUILDDIR}/mahara
# Get the public & security branches
PUBLIC="http://git.mahara.org/git/mahara.git"
SECURITY="git+ssh://git.catalyst.net.nz/var/gitprivate/mahara-security.git"
echo "Cloning public repository $PUBLIC"
git-init
git-remote add -t ${BRANCH} mahara ${PUBLIC}
git fetch mahara
if [ "$OPTION" = "--public" ]; then
REPOSITORY=${PUBLIC}
else
REPOSITORY=${SECURITY}
fi
if [ $REPOSITORY = $PUBLIC ]; then
git checkout -b ${BRANCH} mahara/${BRANCH}
else
echo "Checking out security repository $SECURITY"
git-remote add -t ${BRANCH} mahara-security ${SECURITY}
git fetch mahara-security
git checkout -b S_${BRANCH} mahara-security/${BRANCH}
echo "Merging $BRANCH (public) into $BRANCH (security)"
git merge mahara/${BRANCH}
fi
RELEASE="${MAJOR}.${MINOR}${MICRO}"
# Edit ChangeLog
if [ -f "ChangeLog" ]; then
cp ChangeLog ChangeLog.back
echo "$RELEASE (`date +%Y-%m-%d`)" > ChangeLog
echo "- " >> ChangeLog
echo >> ChangeLog
cat ChangeLog.back >> ChangeLog
sensible-editor ${BUILDDIR}/mahara/ChangeLog
git add ChangeLog
fi
# Version bump for the release
VERSIONFILE=htdocs/lib/version.php
if [ "$BRANCH" = "master" ]; then
NEWVERSION=`date +%Y%m%d`00
else
OLDVERSION=$(perl -n -e 'print if s/^\$config->version = (\d{10}).*/$1/' < ${VERSIONFILE})
NEWVERSION=$(( ${OLDVERSION} + 1 ))
fi
sed "s/\$config->version = [0-9]\{10\};/\$config->version = $NEWVERSION;/" ${VERSIONFILE} > ${VERSIONFILE}.temp
sed "s/\$config->release = .*/\$config->release = '$RELEASE';/" ${VERSIONFILE}.temp > ${VERSIONFILE}
git add ${VERSIONFILE}
git commit -m "Version bump for $RELEASE"
RELEASETAG="`echo $RELEASE | tr '[:lower:]' '[:upper:]'`_RELEASE"
git tag -s ${RELEASETAG} -m "$RELEASE release"
# Create tarballs
echo "Creating mahara-${RELEASE}.tar.gz"
git archive --format=tar ${RELEASETAG} | gzip > ${CURRENTDIR}/mahara-${RELEASE}.tar.gz
echo "Creating mahara-${RELEASE}.tar.bz2"
git archive --format=tar ${RELEASETAG} | bzip2 > ${CURRENTDIR}/mahara-${RELEASE}.tar.bz2
echo "Creating mahara-${RELEASE}.zip"
git archive --format=zip -9 ${RELEASETAG} > ${CURRENTDIR}/mahara-${RELEASE}.zip
# Second version bump for post-release
NEWVERSION=$(( ${NEWVERSION} + 1 ))
if [ "$BRANCH" = "master" ]; then
NEWRELEASE="${MAJOR}.${MINOR}${MICROA}$(( ${MICROB} + 1 ))dev"
else
NEWRELEASE="${MAJOR}.$(( ${MINOR} + 1 ))testing"
fi
sed "s/\$config->version = [0-9]\{10\};/\$config->version = $NEWVERSION;/" ${VERSIONFILE} > ${VERSIONFILE}.temp
sed "s/\$config->release = .*/\$config->release = '$NEWRELEASE';/" ${VERSIONFILE}.temp > ${VERSIONFILE}
git add ${VERSIONFILE}
git commit -m "Version bump for $NEWRELEASE"
exit
popd
rm -rf ${BUILDDIR}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment