Skip to content

Instantly share code, notes, and snippets.

@Scarbous
Created September 15, 2017 13:14
Show Gist options
  • Save Scarbous/e889d9c2285acf7e97729be97ddd39f0 to your computer and use it in GitHub Desktop.
Save Scarbous/e889d9c2285acf7e97729be97ddd39f0 to your computer and use it in GitHub Desktop.
deployer Task to checkout last tag
<?php
task('deploy:release:tag', function(){
$stage = input()->getArgument('stage');
# only in production stage
if (!in_array($stage,['production'])) {
return true;
}
$git = get('bin/git');
$repository = trim(get('repository'));
# get last Tag
$latestTag = run("$git ls-remote --tags $repository | grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*' | sort -r | head | grep -o '[^\/]*$' | uniq");
writeln('last Tag: '.$latestTag);
# go into release path
cd('{{release_path}}');
# Checkout the latest tag
run("$git checkout $latestTag");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment