Implementation:Puppeteer Puppeteer Update Browser Revision
| Property | Value |
|---|---|
| sources | tools/update_browser_revision.mjs |
| domains | Tools, Release Management, CI/CD |
| last_updated | 2026-02-12 00:00 GMT |
Overview
Description
The update_browser_revision tool is a JavaScript script used in Puppeteer's CI/CD pipeline (GitHub Actions) to automatically roll the pinned browser version (Chrome or Firefox) to the latest stable release. It performs version comparison, updates multiple files across the monorepo, and sets GitHub Actions outputs for the commit message.
The script executes the following steps:
- Version resolution -- Reads the BROWSER_TO_UPDATE environment variable to determine which browser to update. Resolves the latest stable build ID using
@puppeteer/browsersresolveBuildId for the Linux platform. - Version comparison -- Compares the new version against the current version from PUPPETEER_REVISIONS. Uses SemVer comparison (with normalization for Firefox's version format). If the new version is not newer, the script exits cleanly. If the major version changes, the commit is prefixed with
feat:; otherwisefix:. - Revision file update -- Replaces the old version string with the new version in
packages/puppeteer-core/src/revisions.ts. - Version data update -- Updates the versions.json file at the repository root, which maps Puppeteer versions to browser versions. If a NEXT entry already exists, it is updated in place; otherwise a new NEXT entry is prepended.
- Chrome-specific updates -- For Chrome updates, the script additionally:
- Updates the lastMaintainedChromeVersion in versions.json (maintaining the latest N-3 major version).
- Fetches the latest DevTools Protocol version matching the Chrome revision from the Chrome for Testing API.
- Updates the devtools-protocol dependency version in both
puppeteer-core/package.jsonandpuppeteer/package.json. - Runs
npm install --ignore-scriptsto regenerate the lockfile.
- Formatting -- Runs ESLint and Prettier on all touched files to ensure they pass CI formatting checks.
- GitHub Actions outputs -- Sets
commit(the commit message) andversion(the new browser version) as GitHub Actions outputs.
Usage
This script is executed by a scheduled GitHub Actions workflow. It requires the BROWSER_TO_UPDATE environment variable to be set to either chrome or firefox.
Code Reference
Source Location
tools/update_browser_revision.mjs
Signature
// Standalone ESM script with the following key functions:
function normalizeVersionForCommit(browser: string, version: string): string;
function normalizeVersionToSemVer(browser: string, version: string): string;
function checkIfNeedsUpdate(browser: string, oldVersion: string, newVersion: string): void;
async function formatUpdateFiles(): Promise<void>;
async function replaceInFile(filePath: string, search: string, replace: string): Promise<void>;
async function getVersionForStable(browser: string): Promise<string>;
async function updateDevToolsProtocolVersion(browserVersion: string): Promise<void>;
async function saveVersionData(): Promise<void>;
async function updateVersionData(browser: string, oldVersion: string, newVersion: string): Promise<void>;
async function updateLastMaintainedChromeVersion(oldVersion: string, newVersion: string): Promise<void>;
Import
// This is a standalone script, not a library module.
// Run: BROWSER_TO_UPDATE=chrome node tools/update_browser_revision.mjs
I/O Contract
| Input | Type | Description |
|---|---|---|
| BROWSER_TO_UPDATE | Environment variable | 'chrome' or 'firefox'
|
| PUPPETEER_REVISIONS | Import | Current browser version constants |
| packages/puppeteer-core/package.json | JSON file | Current devtools-protocol dependency version |
| versions.json | JSON file | Puppeteer-to-browser version mapping |
| Chrome for Testing API | HTTP fetch | Latest known good Chrome versions and revisions |
| npm registry | HTTP fetch (via npm view) | Available devtools-protocol package versions |
| Output | Type | Description |
|---|---|---|
| packages/puppeteer-core/src/revisions.ts | File update | Updated browser version constant |
| packages/puppeteer-core/package.json | File update | Updated devtools-protocol version (Chrome only) |
| packages/puppeteer/package.json | File update | Updated devtools-protocol version (Chrome only) |
| versions.json | File update | Updated version mapping with NEXT entry |
| package-lock.json | File update | Regenerated lockfile (Chrome only) |
| GitHub Actions output: commit | String | Commit message (e.g., "feat: roll to Chrome 128.0.6613.84") |
| GitHub Actions output: version | String | The new browser version string |
Usage Examples
// Run from CI to update Chrome
// BROWSER_TO_UPDATE=chrome node tools/update_browser_revision.mjs
// Run from CI to update Firefox
// BROWSER_TO_UPDATE=firefox node tools/update_browser_revision.mjs
// Example GitHub Actions workflow step:
// - name: Update browser revision
// env:
// BROWSER_TO_UPDATE: chrome
// run: node tools/update_browser_revision.mjs
// - name: Create PR
// run: |
// git add .
// git commit -m "${{ steps.update.outputs.commit }}"