-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathversion.rb
More file actions
24 lines (20 loc) · 840 Bytes
/
version.rb
File metadata and controls
24 lines (20 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "yaml"
# Default to config-v20111101 file if not provided for backwards compatibility
# This is because automated openapi repository dispatch currently only generates v20111101
config_file = ARGV[1] || "openapi/config-v20111101.yml"
config = ::YAML.load(::File.read(config_file))
major, minor, patch = config["npmVersion"].split(".")
# Note: "skip" logic is handled by workflow (version.rb not called when skip selected)
# Only minor and patch bumps are supported (major version locked to API version)
case ARGV[0]
when "minor"
minor = minor.succ
patch = 0
when "patch"
patch = patch.succ
else
raise "Invalid version bump type: #{ARGV[0]}. Supported: 'minor' or 'patch'"
end
config["npmVersion"] = "#{major}.#{minor}.#{patch}"
::File.open(config_file, 'w') { |file| ::YAML.dump(config, file) }
puts config["npmVersion"]