-
Notifications
You must be signed in to change notification settings - Fork 101
/
release-gem
executable file
·90 lines (62 loc) · 2.8 KB
/
release-gem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/env ruby
$plugin_name = "foreman_discovery"
RUBY_VERSION_FILE = "lib/#{$plugin_name}/version.rb"
JS_VERSION_FILE = "package.json"
def die(msg)
warn msg
exit 1
end
def run(cmd)
puts `#{cmd}`
die("Command #{cmd} failed with #{$?}!") if $?.to_i != 0
true
end
def action(question)
puts "#{question} ? [Y/n]"
die("Aborted.") if STDIN.gets.chomp.match(/^(n|no|nope)$/i)
die("Check failed, exiting.") if block_given? && !yield
end
action "Extracted strings with: rake plugin:gettext[#{$plugin_name}] (Foreman dir)"
action "Announced incoming strings on Transifex days before the release"
action "Tested #{$plugin_name} plugin against stable Foreman core"
action "Pulled updates with: make -C locale tx-update"
action "Merged the updates with: rake plugin:gettext[#{$plugin_name}] (Foreman dir)"
action "Rebuilt the MO files with: make -C locale mo-files" do
Dir["locale/**/*.po"].each do |po|
mo = po.sub(/#{$plugin_name}\.po$/, "LC_MESSAGES/#{$plugin_name}.mo")
puts("Warning, file #{mo} does not exist!") unless File.exist?(mo)
puts("Warning, file #{mo} outdated!") if File.mtime(po) > File.mtime(mo)
end
end
action "Want me to update AUTHORS file" do
run "git log --pretty=format:'%an' | sort -u > AUTHORS"
end
action "Modified lib/foreman_discovery/engine.rb to match minimum Foreman core version"
action "Modified #{RUBY_VERSION_FILE} to match the desired version"
action "Created 'Version X.Y' commit with engine.rb/version.rb change"
action "Created git tag" do
$git_version = `git describe --abbrev=0 --tags`.chomp
$git_version == File.read(RUBY_VERSION_FILE).match(/VERSION\s*=\s"([0-9\.]+)"/)[1]
end
action "Modified #{JS_VERSION_FILE} to match the desired version"
action "Is version #{$git_version} the one to be released"
$gem_filename = "#{$plugin_name}-#{$git_version}.gem"
action "Shall I build the #{$gem_filename} now" do
run "gem build #{$plugin_name}.gemspec"
end
action "Investigated the #{$gem_filename} via gem compare -k -b foreman_discovery OLD #{$git_version} -k" do
run "tar -xOf #{$gem_filename} data.tar.gz | tar -z -list | sort"
end
action "Created and built OS distribution packages"
action "Updated dependencies in both RPM and DEB spec files"
action "All commits and *tags* pushed to origin"
action "Shell I push the #{$gem_filename} to rubygems.org now" do
run "gem push #{$gem_filename}"
end
action "Is https://rubygems.org/gems/#{$plugin_name} looking good"
action "Created new stable branch and pushed to origin"
action "Updated documentation?"
action "Update https://github.com/theforeman/jenkins-jobs/blob/master/theforeman.org/yaml/jobs/plugins/foreman_discovery.yaml"
puts "Well done! Go ahead and create documentation and changelog:"
puts " git log --pretty=format:'%s' develop...X.Y.Z"
puts " git log --pretty=format:'%an' develop...X.Y.Z | sort -u"