class Object

Public Instance Methods

fly_deploy(args=[]) click to toggle source
# File lib/github-release-party/tasks/fly.rb, line 5
def fly_deploy(args=[])
  # grab the new version number from the "fly deploy" output
  cmd = %w[fly deploy] + args
  ver = Open3.popen2e(*cmd) do |stdin, output, thread|
    v = nil
    output.each do |line|
      puts line
      if /--> release (v\d+) created/ =~ line
        v = $~[1]
      end
    end
    v
  end
  return ver
end
github_tag(hash, ver) click to toggle source
# File lib/github-release-party/tasks/fly.rb, line 21
def github_tag(hash, ver)
  # build tag message
  repo = GithubReleaseParty.repo
  tag_name = "fly/#{ver}"
  last_tag = `git describe --tags --abbrev=0 --match 'fly/v*' 2> /dev/null`.strip
  if last_tag.empty?
    # first deploy, use root hash
    last_tag = `git rev-list --max-parents=0 HEAD`.strip[0..6]
    first_deploy = true
  end
  commits = `git log #{last_tag}..#{hash} --reverse --first-parent --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
  message = "Deploy #{hash[0..6]}\n\nDiff: https://github.com/#{repo}/compare/#{last_tag}...#{tag_name}\n#{commits}"

  if first_deploy
    message = "#{message.strip}\n"+`git show #{last_tag} -s --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
  end

  # tag and push new tag
  puts
  puts "Tagging #{tag_name}."
  success = system "git tag -a -m #{Shellwords.shellescape(message)} #{tag_name} #{hash}"
  abort if not success
  puts
  success = system "git push origin #{tag_name}"
  abort if not success

  # create GitHub release
  puts
  puts "Waiting 3 seconds to let GitHub process the new tag."
  sleep(3)
  GithubReleaseParty.create(tag_name, message)
end
heroku_push(args=[]) click to toggle source
# File lib/github-release-party/tasks/heroku.rb, line 5
def heroku_push(args=[])
  # grab the new version number from the Heroku push output
  cmd = %w[git push heroku HEAD:master] + args
  ver = Open3.popen2e(*cmd) do |stdin, output, thread|
    v = nil
    output.each do |line|
      puts line
      if /Released (v\d+)/ =~ line
        v = $~[1]
      end
    end
    v
  end
  return ver
end