Skip to content

Instantly share code, notes, and snippets.

@nightcrawler-
Forked from caok/gist:4065758
Created November 10, 2020 23:45
Show Gist options
  • Save nightcrawler-/0667911c8d589a76d82da9ea82332cf4 to your computer and use it in GitHub Desktop.
Save nightcrawler-/0667911c8d589a76d82da9ea82332cf4 to your computer and use it in GitHub Desktop.
Deploy from a git tag with capistrano
ref: http://nathanhoad.net/deploy-from-a-git-tag-with-capistrano
Deploy from a Git tag with Capistrano
Are you using Capistrano and Git and want to easily deploy from Git tags? It couldn't be simpler
Using Git, tag a new release:
git tag -a 09.10.02.01 -m "Tagging a release"
You can use git tag to list your tags:
git tag
09.10.01.01
09.10.01.02
09.10.02.01
Now make sure you push your tags to the central repository:
git push origin --tags
Now in your Capsitrano deploy script:
set :branch do
default_tag = `git tag`.split("\n").last
tag = Capistrano::CLI.ui.ask "Tag to deploy (make sure to push the tag first): [#{default_tag}] "
tag = default_tag if tag.empty?
tag
end
This will, on deployment, ask you which tag you want to deploy from (defaulting to the most recent tag).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment