|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This helps you get a new version from GIT and deploy it |
| 4 | +# to /var/illuminatus on egcloud. Change to that directory |
| 5 | +# before running it. |
| 6 | +# It is "safe" in that it won't clobber anything. I promise. |
| 7 | + |
| 8 | +# To prep for first release: |
| 9 | +# git init --bare --shared git_repo |
| 10 | +# git --git-dir=git_repo remote add origin [email protected]:EdinburghGenomics/illuminatus.git |
| 11 | +# git --git-dir=git_repo fetch --all |
| 12 | + |
| 13 | +die(){ echo $@ ; exit 1 ; } |
| 14 | +runcmd(){ echo "RUNNING: $@" ; "$@" ; } |
| 15 | + |
| 16 | +# Sanity checking stage... |
| 17 | +[ -d git_repo ] || die "No git_repo folder."\ |
| 18 | + "This script should normally be run in /var/illuminatus/ on egcloud" |
| 19 | + |
| 20 | +# Update the git_repo. This doesn't affect any actual working files. |
| 21 | +# Note - if the tag doesn't appear to be fetched then make sure you |
| 22 | +# tagged it on the master branch! |
| 23 | +runcmd git --git-dir=git_repo fetch --all |
| 24 | +runcmd git --git-dir=git_repo repack -ad |
| 25 | + |
| 26 | +#Note this assumes the tags are all of the form v0.0.0 and ignores others. |
| 27 | +#The top tag will be the latest. |
| 28 | +listtags(){ |
| 29 | + git --git-dir=git_repo log --tags --simplify-by-decoration --pretty="format:%d" |\ |
| 30 | + grep -o 'tag: v[0-9][^,)]*' | awk '{print $2}' |
| 31 | +} |
| 32 | + |
| 33 | +# Find the latest tag in the repo |
| 34 | +latest_tag="`listtags | head -n1`" |
| 35 | + |
| 36 | +# Find the latest tag from the repo for which there is a directory |
| 37 | +latest_checked_out="NONE" |
| 38 | +for tag in `listtags` ; do |
| 39 | + if [ -e "$tag" ] ; then |
| 40 | + latest_checked_out="$tag" |
| 41 | + break |
| 42 | + fi |
| 43 | +done |
| 44 | + |
| 45 | +# Check we saw something |
| 46 | +[ -z "$latest_tag" ] && die "No tags found in GIT" |
| 47 | + |
| 48 | +# See if the latest tag already exists as a directory |
| 49 | +[ -d "$latest_tag" ] && die "The latest tag - $latest_tag - is already checked out." |
| 50 | + |
| 51 | +# So we know there is no folder for latest_tag, it's safe to create one and populate it |
| 52 | +runcmd mkdir "$latest_tag" |
| 53 | +runcmd git --git-dir=git_repo --work-tree="$latest_tag" checkout -f tags/"$latest_tag" |
| 54 | + |
| 55 | +# Sanity check |
| 56 | +[ -d "$latest_checked_out" ] || die "Could not read folder for tag $latest_checked_out" |
| 57 | + |
| 58 | +# Copy the config file |
| 59 | +cp -vn -t $latest_tag $latest_checked_out/environ.sh |
| 60 | + |
| 61 | +# Remove the test directory which we do not need, and the driver which we do not need to run |
| 62 | +rm -rf "$latest_tag/test" "$latest_tag/driver.sh" |
| 63 | + |
| 64 | +runcmd ln -snf $latest_tag current |
| 65 | +echo "Checked out version $latest_tag, and updated the symlink:" |
| 66 | +ls -l |
0 commit comments