Skip to content

Commit

Permalink
build: update version roll script
Browse files Browse the repository at this point in the history
major version rolls will result in
a feature commit, that would bump
the package version in a way that
allows for patch releases for the
previus major browser version.
  • Loading branch information
OrKoN committed Aug 31, 2024
1 parent 318d621 commit c70bfad
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/update-browser-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ jobs:
- name: Update browser pin and devtools-protocol
run: node tools/update_chrome_revision.mjs
- name: Create Pull Request
if: ${{ steps.update.outputs.commit }}
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }}
branch: browser-automation-bot/update-browser-version
delete-branch: true
committer: Browser Automation Bot <[email protected]>
author: Browser Automation Bot <[email protected]>
commit-message: 'build(chrome): update the pinned browser version'
title: 'build(chrome): update the pinned browser version'
commit-message: ${{ steps.update.outputs.commit }}
title: ${{ steps.update.outputs.commit }}
body: 'Automatically generated by https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/.github/workflows/update-browser-version.yml'
push-to-fork: browser-automation-bot/chromium-bidi
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"rollup": "4.21.0",
"rollup-plugin-license": "3.5.2",
"selenium-webdriver": "4.23.0",
"semver": "7.6.3",
"sinon": "18.0.0",
"source-map-support": "0.5.21",
"tslib": "2.7.0",
Expand Down
26 changes: 26 additions & 0 deletions tools/update_chrome_revision.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import {execSync} from 'child_process';
import {writeFile, readFile} from 'fs/promises';

import actions from '@actions/core';
import {SemVer} from 'semver';

import packageJson from '../package.json' assert {type: 'json'};

async function getVersionAndRevisionForCanary() {
Expand Down Expand Up @@ -57,7 +60,30 @@ async function updateDevToolsProtocolVersion(revision) {
await writeFile('./package.json', update);
}

const currentVersion = (await readFile('./browser', 'utf8')).split('@').pop();
console.log(`Current pinned version is: ${currentVersion}`);

const {version, revision} = await getVersionAndRevisionForCanary();

const oldSemVer = new SemVer(currentVersion, true);
const newSemVer = new SemVer(version, true);

let message = `update the pinned browser version to ${version}`;

if (newSemVer.compare(oldSemVer) <= 0) {
// Exit the process without setting up version
console.warn(
`Version ${version} is older or the same as the current ${currentVersion}`
);
process.exit(0);
} else if (newSemVer.major === oldSemVer.major) {
message = `build(chrome): ${message}`;
} else {
message = `feat(chrome): ${message}`;
}

actions.setOutput('commit', message);

console.log(`Chrome Canary version is: ${version} (${revision})`);
await updateDevToolsProtocolVersion(revision);

Expand Down

0 comments on commit c70bfad

Please sign in to comment.