Skip to content

Instantly share code, notes, and snippets.

@jamiepenney

jamiepenney/do-release.sh

Last active Aug 29, 2015
Embed
What would you like to do?
#!/bin/bash
SERVER="your octopus server here"
APIKEY="your api key here"
VERSION=""
TEST=0
REUSE_NOTES=0
DEPLOY_TARGET="Office"
DEPLOY_ONLY=0
while getopts "v:tre:d" opt; do
case $opt in
v)
VERSION=$OPTARG
;;
t)
TEST=1
;;
r)
REUSE_NOTES=1
;;
e)
DEPLOY_TARGET=$OPTARG
;;
d)
REUSE_NOTES=1
DEPLOY_ONLY=1
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
nl=$'\n'
branch=`git symbolic-ref --short HEAD`
user=`id -u -n`
if [ $REUSE_NOTES -eq 0 ]
then
rm -f /tmp/releasenotes
echo "# $branch $nl* $nl#### $user" > /tmp/releasenotes
fi
if [ $DEPLOY_ONLY -eq 0 ]
then
vim +2 /tmp/releasenotes
fi
while [[ $# -gt 0 ]]
do
command="octo create-release --project=\"$1\" --packageversion=\"$VERSION\" --releasenotesfile=/tmp/releasenotes --deployto=$DEPLOY_TARGET --server=$SERVER --apiKey=$APIKEY"
if [ $DEPLOY_ONLY -eq 1 ]
then
command="octo deploy-release --project=\"$1\" --releaseNumber=\"$VERSION\" --deployto=$DEPLOY_TARGET --server=$SERVER --apiKey=$APIKEY"
fi
if [ $TEST -eq 0 ]
then
eval $command
else
echo $command
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment