Created
September 15, 2017 13:14
-
-
Save Scarbous/e889d9c2285acf7e97729be97ddd39f0 to your computer and use it in GitHub Desktop.
deployer Task to checkout last tag
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
<?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