forked from gocd/build_utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs_next_version.rb
More file actions
executable file
·24 lines (17 loc) · 866 Bytes
/
docs_next_version.rb
File metadata and controls
executable file
·24 lines (17 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby
require 'date'
def validate(key)
value = ENV[key].to_s.strip
fail "Please specify #{key}" if value == ''
fail "Specify a valid version" unless value =~ /\d+\.\d+\.\d+/
value
end
version_to_release = validate('VERSION_TO_RELEASE')
segments_of_version_to_release = Gem::Version.new(version_to_release).segments
# The below if logic is only for December and the assumption is we make one release at that time of the year. We can revisit if we make more than one release in December.
if (Date.today() + 31).strftime('%y') == segments_of_version_to_release[0].to_s
next_version = [segments_of_version_to_release[0], segments_of_version_to_release[1] + 1, 0].join('.')
else
next_version = [(Date.today() + 31).strftime('%y'), 1, 0].join('.')
end
File.open('version', 'w') { |file| file.write("export NEXT_VERSION=#{next_version}") }