Module: Radius::Toolbelt::ReleaseHelpers

Defined in:
lib/radius/toolbelt/release_helpers.rb

Instance Method Summary collapse

Instance Method Details

#clean(dir) ⇒ Object



38
39
40
41
# File 'lib/radius/toolbelt/release_helpers.rb', line 38

def clean(dir)
  rm_rf Dir.glob("#{dir}/*.framework")
  rm_rf Dir.glob("#{dir}/*.zip")
end

#current_versionObject



16
17
18
# File 'lib/radius/toolbelt/release_helpers.rb', line 16

def current_version
  @current_version ||= File.read("VERSION").chomp
end

#github_tokenObject



34
35
36
# File 'lib/radius/toolbelt/release_helpers.rb', line 34

def github_token
  @token ||= ENV["GITHUB_TOKEN"] || YAML.load(`cat ~/.config/hub`)["github.com"].first["oauth_token"]
end

#release_github(repo, release_name, version, files, &block) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/radius/toolbelt/release_helpers.rb', line 54

def release_github(repo, release_name, version, files, &block)
  tag_name = "v#{version}"
  body = <<EOF
Bug Fixes:

 - TODO: Describe any bug fixes

Enhancements:

 - TODO: Describe any new features or enhancements

Deprecations:

 - TODO: Describe any deprecations
EOF
  token = github_token

  r = ReleaseGithub.new repo, token, tag_name, release_name, body, files
  r.run(&block)
end

#release_repo(repo, version, dir, files) ⇒ Object

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.



47
48
49
50
51
# File 'lib/radius/toolbelt/release_helpers.rb', line 47

def release_repo(repo, version, dir, files)
  dir = File.join "build", File.basename(repo)
  r = ReleaseRepo.new repo, version, dir, files
  r.run
end

#replace(src, dest) ⇒ Object



30
31
32
# File 'lib/radius/toolbelt/release_helpers.rb', line 30

def replace(src, dest)
  FileUtils.copy_entry(src, dest, false, false, true)
end

#sanitized_versionObject



20
21
22
# File 'lib/radius/toolbelt/release_helpers.rb', line 20

def sanitized_version
  @sanitized_version ||= /([0-9\.]+)/.match(current_version)[0]
end

#tag_version(ver) ⇒ Object



24
25
26
27
28
# File 'lib/radius/toolbelt/release_helpers.rb', line 24

def tag_version(ver)
  unless system("git tag v#{ver}")
    fail "Error: the tag v#{ver} already exists on this repo."
  end
end

#validate_clean_git!Object



6
7
8
# File 'lib/radius/toolbelt/release_helpers.rb', line 6

def validate_clean_git!
  fail "There are uncommitted changes in git" unless system("git diff-files --quiet")
end

#validate_version_for_repo!(repo) ⇒ Object



10
11
12
13
14
# File 'lib/radius/toolbelt/release_helpers.rb', line 10

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