lib/radius/toolbelt/release_helpers.rb in radius-toolbelt-0.0.7 vs lib/radius/toolbelt/release_helpers.rb in radius-toolbelt-0.0.8

- old
+ new

@@ -1,31 +1,59 @@ require 'fileutils' module Radius module Toolbelt module ReleaseHelpers + def validate_clean_git! + fail "There are uncommitted changes in git" unless system("git diff-files --quiet") + end + def validate_version_for_repo!(repo) + ver = `cd #{repo} && agvtool what-version -terse`.chomp + puts "Validating matching version for #{repo}: #{ver}" + fail "Versions do not match (version file: #{ver} #{repo} version: #{sanitized_version}" unless (ver == sanitized_version) + end + + def current_version + @current_version ||= File.read("VERSION").chomp + end + + def sanitized_version + @sanitized_version ||= /([0-9\.]+)/.match(current_version)[0] + end + def tag_version(ver) - unless system("git tag v#{agvtool_version}") - fail "Error: the tag v#{agvtool_version} already exists on this repo." + unless system("git tag v#{ver}") + fail "Error: the tag v#{ver} already exists on this repo." end end def replace(src, dest) FileUtils.copy_entry(src, dest, false, false, true) end def github_token - @token ||= ENV["github_token"] || YAML.load(`cat ~/.config/hub`)["github.com"].first["oauth_token"] + @token ||= ENV["GITHUB_TOKEN"] || YAML.load(`cat ~/.config/hub`)["github.com"].first["oauth_token"] end def clean(dir) rm_rf Dir.glob("#{dir}/*.framework") rm_rf Dir.glob("#{dir}/*.zip") end - def release_github(repo, release_name, version, files) + # Clone down the `repo`, copy all the `file` over then commit, tag and push + # it up to the origin. + # + # `files` is an array of files to copy into the root of the local repo. + def release_repo(repo, version, dir, files) + dir = File.join "build", File.basename(repo) + r = ReleaseRepo.new repo, version, dir, files + r.run + end + + + def release_github(repo, release_name, version, files, &block) tag_name = "v#{version}" body = <<EOF Bug Fixes: - TODO: Describe any bug fixes @@ -39,19 +67,10 @@ - TODO: Describe any deprecations EOF token = github_token r = ReleaseGithub.new repo, token, tag_name, release_name, body, files - r.run - end - - # Clone down the `repo`, copy all the `file` over then commit, tag and push - # it up to the origin. - # - # `files` is an array of files to copy into the root of the local repo. - def release_repo(repo, version, files, dir = "build/release-repo") - r = ReleaseRepo.new repo, version, dir, files - r.run + r.run(&block) end end end end