-
-
Save tlehman/5241261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function today { | |
echo `date +"%Y%m%d"` | |
} | |
function last_tag_today { | |
output=`git tag` | |
local last_today='' | |
for LINE in ${output} ; do | |
if [[ $LINE =~ $(today) ]] ; then | |
last_today=${LINE} | |
fi | |
done | |
echo $last_today | |
} | |
function new_tag_name { | |
git fetch --tags | |
last_today=$(last_tag_today) | |
if [ "$last_today" ] ; then | |
tag_date=$((${last_today/#release-/}+1)) | |
echo 'release-'$tag_date | |
else | |
echo 'release-'$(today)'01' | |
fi | |
} | |
function tag_master { | |
new_tag=$(new_tag_name) | |
echo 'Creating '$new_tag'...' | |
git tag -a $new_tag -m 'Creating '$new_tag | |
echo 'Pushing tag...' | |
git push origin $new_tag | |
echo 'Tag '$new_tag' created and pushed.' | |
} | |
function destination { | |
case "$1" in | |
'1') | |
echo 'i cap rails3_staging deploy -s revision=' | |
;; | |
'2') | |
echo 'i cap rails3_staging deploy:migrations -s revision=' | |
;; | |
'3') | |
echo 'cap staging deploy -s revision=' | |
;; | |
'4') | |
echo 'cap staging deploy:migrations -s revision=' | |
;; | |
'5') | |
echo 'i cap production deploy -s revision=' | |
;; | |
'6') | |
echo 'i cap production deploy:migrations -s revision=' | |
;; | |
'7') | |
echo 'cap production deploy -s revision=' | |
;; | |
'8') | |
echo 'cap production deploy:migrations -s revision=' | |
;; | |
esac | |
} | |
function deploy { | |
echo 'Deploy to:' | |
echo '1. Goldstar staging' | |
echo '2. Goldstar staging with migrations' | |
echo '3. Fulfillment staging' | |
echo '4. Fulfillment staging with migrations' | |
echo '5. Goldstar production' | |
echo '6. Goldstar production with migrations' | |
echo '7. Fulfillment production' | |
echo '8. Fulfillment production with migrations' | |
echo -n '-> ' | |
read dest | |
deploy_dest=$(destination $dest) | |
branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
branch_name=${branch_name:-HEAD} | |
if [ -z "$new_tag" ] ; then | |
new_tag=$branch_name | |
fi | |
echo -n 'Revision to deploy (leave blank for '$new_tag'): ' | |
read dest | |
if [ -z "$dest" ] ; then | |
eval $deploy_dest$new_tag | |
else | |
eval $deploy_dest$dest | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment