Skip to content

Commit 538c11a

Browse files
committed
Publish nightly versions of Ruby gems every day
Creates new workflow that automatically publishes nightly versions of Ruby gems (selenium-devtools, selenium-webdriver) to GitHub Packages. Every nightly package is versioned in the following manner: <current-version>.nightly.<YYYmmdd> Installation via Bundler can done by adding following to Gemfile: source "https://rubygems.pkg.github.com/seleniumhq" do gem "selenium-webdriver", "~> 4.6.1.pre" # replace 4.6.1 with the latest version end Then running: BUNDLE_RUBYGEMS__PKG__GITHUB__COM="USERNAME:TOKEN" bundle install Installation via RubyGems can done by running: gem install selenium-webdriver --pre --clear-sources --source "https://USERNAME:TOKEN@rubygems.pkg.github.com/seleniumhq" For more details on authentication and installation from GitHub Packages, check out https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry#installing-a-package. To publish manually, run the following Bazel targets: bazel run rb:webdriver-bump-nightly-version GEM_HOST_API_KEY="Bearer TOKEN" bazel run rb:selenium-webdriver-release-nightly Replace `webdriver` with `devtools` to publish selenium-devtools.
1 parent ab38b9c commit 538c11a

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Nightly
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: Nightly version number (e.g. 20221125)
9+
required: true
10+
type: string
11+
12+
jobs:
13+
ruby:
14+
name: Ruby Gems
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
gem:
20+
- selenium-devtools
21+
- selenium-webdriver
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: actions/setup-java@v1
25+
with:
26+
java-version: 11
27+
- uses: ./.github/actions/cache-bazel
28+
with:
29+
workflow: ruby
30+
key: bazel-ruby-nightly-${{ matrix.gem }}
31+
- uses: ./.github/actions/bazel
32+
with:
33+
command: run //rb:${{ matrix.gem }}-bump-nightly-version ${{ inputs.version }}
34+
- uses: ./.github/actions/bazel
35+
env:
36+
GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
37+
with:
38+
command: run //rb:${{ matrix.gem }}-release-nightly

rb/BUILD.bazel

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ CDP_VERSIONS = [
1818
"v107",
1919
]
2020

21+
GITHUB_PACKAGES_HOST = "https://rubygems.pkg.github.com/SeleniumHQ"
22+
2123
exports_files(["ruby_version.bzl"])
2224

2325
copy_file(
@@ -123,6 +125,48 @@ rb_gem_push(
123125
src = ":selenium-devtools",
124126
)
125127

128+
rb_binary(
129+
name = "webdriver-bump-nightly-version",
130+
srcs = [
131+
"lib/selenium/webdriver/support/nightly_version_generator.rb",
132+
"lib/selenium/webdriver/version.rb",
133+
],
134+
args = [
135+
"rb/lib/selenium/webdriver/support/nightly_version_generator.rb",
136+
"rb/lib/selenium/webdriver/version.rb",
137+
],
138+
)
139+
140+
rb_gem_push(
141+
name = "selenium-webdriver-release-nightly",
142+
src = ":selenium-webdriver",
143+
args = [
144+
"--host",
145+
GITHUB_PACKAGES_HOST,
146+
],
147+
)
148+
149+
rb_binary(
150+
name = "devtools-bump-nightly-version",
151+
srcs = [
152+
"lib/selenium/devtools/version.rb",
153+
"lib/selenium/webdriver/support/nightly_version_generator.rb",
154+
],
155+
args = [
156+
"rb/lib/selenium/webdriver/support/nightly_version_generator.rb",
157+
"rb/lib/selenium/devtools/version.rb",
158+
],
159+
)
160+
161+
rb_gem_push(
162+
name = "selenium-devtools-release-nightly",
163+
src = ":selenium-devtools",
164+
args = [
165+
"--host",
166+
GITHUB_PACKAGES_HOST,
167+
],
168+
)
169+
126170
rb_library(
127171
name = "bidi",
128172
srcs = glob([
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Unless required by applicable law or agreed to in writing,
3+
# software distributed under the License is distributed on an
4+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
5+
# KIND, either express or implied. See the License for the
6+
# specific language governing permissions and limitations
7+
# under the License.
8+
9+
require 'date'
10+
11+
module Selenium
12+
module WebDriver
13+
module Support
14+
15+
#
16+
# Updates version in `version.rb` file with nightly suffix:
17+
# - VERSION = '4.6.1'
18+
# + VERSION = '4.6.1.nightly.20221126'
19+
#
20+
# @api private
21+
#
22+
23+
class NightlyVersionGenerator
24+
25+
REGEXP = /VERSION = ['"]([\d\.]+)['"]/
26+
27+
def self.call(version_file, version_suffix)
28+
version_suffix ||= Date.today.strftime('%Y%m%d')
29+
version_file_contents = File.read(version_file)
30+
version_file_contents.gsub!(REGEXP) do
31+
old_version = Regexp.last_match(1)
32+
new_version = [old_version, 'nightly', version_suffix].join('.')
33+
puts("#{old_version} -> #{new_version}")
34+
35+
"VERSION = '#{new_version}'"
36+
end
37+
38+
File.write(version_file, version_file_contents)
39+
end
40+
41+
end # NightlyVersionGenerator
42+
end # Support
43+
end # WebDriver
44+
end # Selenium
45+
46+
if __FILE__ == $PROGRAM_NAME
47+
version_file, version_suffix = *ARGV
48+
Selenium::WebDriver::Support::NightlyVersionGenerator.call(version_file, version_suffix)
49+
end

rb/selenium-devtools.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
2323
s.homepage = 'https://selenium.dev'
2424
s.metadata = {
2525
'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
26+
'github_repo' => 'ssh://github.com/SeleniumHQ/selenium',
2627
'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
2728
'rubygems_mfa_required' => 'true'
2829
}

rb/selenium-webdriver.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
2424
s.homepage = 'https://selenium.dev'
2525
s.metadata = {
2626
'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
27+
'github_repo' => 'ssh://github.com/SeleniumHQ/selenium',
2728
'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
2829
'rubygems_mfa_required' => 'true'
2930
}

0 commit comments

Comments
 (0)