forked from Wargus/wargus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.rb
66 lines (54 loc) · 1.24 KB
/
release.rb
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
#!/usr/bin/env ruby
require "pp"
STRINGS = {
version: "3.1.3",
homepage: "https://wargus.github.io",
license: "GPL v2+",
copyright: "(c) 1998-2021 by The Stratagus Project"
}
FILES = %w[wargus.rc wargus.nsi wartool.h mac/Info.plist scripts/stratagus.lua debian/copyright]
FILES << __FILE__
begin
args = ARGV.map do |arg|
if arg.start_with? "--"
arg.sub("--", "").to_sym
else
arg
end
end
input = Hash.[](*args)
rescue Exception
end
if input.nil? || input.empty? || (input.keys - STRINGS.keys).size > 0
puts 'You can update the following STRINGS by passing --key "new-value"'
pp STRINGS
exit
end
if input[:version]
STRINGS[:viversion] = STRINGS[:version].gsub(".", ",")
input[:viversion] = input[:version].gsub(".", ",")
end
FILES.each do |name|
File.open(name, 'a+') do |f|
content = f.read
f.truncate(0)
input.each_pair do |k, v|
content.gsub!(STRINGS[k], v)
end
f.write(content)
end
end
if input[:version]
system("dch -v#{input[:version]}-1")
puts <<EOF
To release, run this:
# mark debian package as release
dch -r
# review changes
git add --patch
# commit and tag
git commit -m "Release #{input[:version]}"
git tag v#{input[:version]}
git push --tags
EOF
end