Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/support/nightly_version_generator.rb
1864 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require 'date'
21
22
module Selenium
23
module Support
24
#
25
# Updates version in `version.rb` file with nightly suffix:
26
# - VERSION = '4.6.1'
27
# + VERSION = '4.6.1.nightly.20221126'
28
#
29
# @api private
30
#
31
32
class NightlyVersionGenerator
33
REGEXP = /VERSION = ['"]([\d.]+\.nightly)['"]/
34
35
def self.call(version_file, version_suffix)
36
version_suffix ||= Date.today.strftime('%Y%m%d')
37
version_file_contents = File.read(version_file)
38
version_file_contents.gsub!(REGEXP) do
39
old_version = Regexp.last_match(1)
40
new_version = [old_version, version_suffix].join('.')
41
puts("#{old_version} -> #{new_version}")
42
43
"VERSION = '#{new_version}'"
44
end
45
46
File.write(version_file, version_file_contents)
47
end
48
end # NightlyVersionGenerator
49
end # Support
50
end # Selenium
51
52
if __FILE__ == $PROGRAM_NAME
53
version_file, version_suffix = *ARGV
54
Selenium::Support::NightlyVersionGenerator.call(version_file, version_suffix)
55
end
56
57