forked from koffeinfrei/MinusShare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versionize.rb
40 lines (34 loc) · 1.41 KB
/
versionize.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
require 'fileutils'
require 'uuidtools'
# current version
puts %Q(> current version: #{File.read("version.txt")[/\d+\.\d+\.\d+/]})
# ask for version
puts "> enter version (format x.x.x)..."
version = STDIN.gets.chomp
fail "error: '#{version}' is not in the format 'x.x.x'." unless version.match(/^\d+\.\d+\.\d+$/)
version += '.0'
# generate required new guids
ProductCodeGuid = UUIDTools::UUID.random_create.to_s.upcase
PackageCodeGuid = UUIDTools::UUID.random_create.to_s.upcase
# update version and guids for setup.vdproj
['version.txt',
'Koffeinfrei.MinusShare/Properties/AssemblyInfo.cs'].each do |filename|
puts "> updating '#{filename}'..."
contents = File.read(filename)
File.open(filename, 'w') do |file|
file.puts contents
.gsub(/\d+\.\d+\.\d+\.\d+/, "#{version}")
end
end
['Koffeinfrei.MinusShare.Setup/Koffeinfrei.MinusShare.Setup.vdproj'].each do |filename|
puts "> updating '#{filename}'..."
contents = File.read(filename)
File.open(filename, 'w') do |file|
file.puts contents
.gsub(/("ProductVersion" = "8:)\d+\.\d+\.\d+"/, "\\1#{version[/\d+\.\d+\.\d+/]}\"")
.gsub(/("ProductCode" = "8:){[^}]+}"/, "\\1{#{ProductCodeGuid}}\"")
.gsub(/("PackageCode" = "8:){[^}]+}"/, "\\1{#{PackageCodeGuid}}\"")
end
end
# done
puts '> done.', "> increase the base library's version if the library was updated!!"