davideisinger.com

My personal website
Log | Files | Refs | README

index.md (3050B)


      1 ---
      2 title: "“What’s new since the last deploy?”"
      3 date: 2014-03-11T00:00:00+00:00
      4 draft: false
      5 canonical_url: https://www.viget.com/articles/whats-new-since-the-last-deploy/
      6 ---
      7 
      8 Managing deployments is one of the trickier aspects of creating software
      9 for the web. Several times a week, a project manager will ask the dev
     10 team something to the effect of "what's new since the last deploy?" --
     11 if we did a deploy right now, what commits would that include?
     12 Fortunately, the tooling around this stuff has never been better (as Tim
     13 Bray says, ["These are the good old
     14 days."](https://www.tbray.org/ongoing/When/201x/2014/01/01/Software-in-2014#p-8)).
     15 Easy enough to pull this info via command line and paste a list into
     16 Campfire, but if you're using GitHub and Capistrano, here's a nifty way
     17 to see this information on the website without bothering the team. As
     18 the saying goes, teach a man to `fetch` and whatever shut up.
     19 
     20 ## Tag deploys with Capistrano
     21 
     22 The first step is to tag each deploy. Drop this recipe in your
     23 `config/deploy.rb` ([original
     24 source](http://wendbaar.nl/blog/2010/04/automagically-tagging-releases-in-github/)):
     25 
     26 ```ruby
     27 namespace :git do
     28   task :push_deploy_tag do
     29     user = `git config --get user.name`.chomp
     30     email = `git config --get user.email`.chomp
     31     puts `git tag #{stage}-deploy-#{release_name} #{current_revision} -m "Deployed by #{user} <#{email}>"`
     32     puts `git push --tags origin`
     33   end
     34 end
     35 ```
     36 
     37 Then throw a `after 'deploy:restart', 'git:push_deploy_tag'` into the
     38 appropriate deploy environment files. Note that this task works with
     39 Capistrano version 2 with the
     40 [capistrano-ext](https://rubygems.org/gems/capistrano-ext) library. For
     41 Cap 3, check out [this
     42 gist](https://gist.github.com/zporter/3e70b74ce4fe9b8a17bd) from
     43 [Zachary](https://viget.com/about/team/zporter).
     44 
     45 ## GitHub Tag Interface
     46 
     47 Now that you're tagging the head commit of each deploy, you can take
     48 advantage of an (as far as I can tell) unadvertised GitHub feature: the
     49 tags interface. Simply visit (or have your PM visit)
     50 `github.com/<organization>/<repo>/tags` (e.g.
     51 <https://github.com/rails/rails/tags>) to see a list of tags in reverse
     52 chronological order. From here, they can click the most recent tag
     53 (`production-deploy-2014...`), and then the link that says "\[N\]
     54 commits to master since this tag" to see everything that would go out in
     55 a new deploy. Or if you're more of a visual learner, here's a gif for
     56 great justice:
     57 
     58 ![](demo.gif)
     59 
     60 ------------------------------------------------------------------------
     61 
     62 This approach assumes a very basic development and deployment model,
     63 where deploys are happening straight from the same branch that features
     64 are being merged into. As projects grow more complex, [so must your
     65 deployment
     66 model](https://viget.com/advance/successful-release-management-and-how-to-communicate-about-it).
     67 Automatically tagging deploys as we've outlined here breaks down under
     68 more complex systems, but the GitHub tag interface continues to provide
     69 value if you're tagging your deploys in any manner.