From 0d219c79de0ad4ae9ef689a731351514497dc00b Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Wed, 14 Jun 2023 09:59:01 +0200 Subject: [PATCH] ci: fix updating Chrome (#10382) --- .github/workflows/issue-analyzer.yml | 2 +- .github/workflows/pre-release.yml | 5 +++-- tools/update_chrome_revision.mjs | 26 ++++++++++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/issue-analyzer.yml b/.github/workflows/issue-analyzer.yml index 48218324..7ac958fc 100644 --- a/.github/workflows/issue-analyzer.yml +++ b/.github/workflows/issue-analyzer.yml @@ -60,7 +60,7 @@ jobs: with: node-version: lts/* - name: Install dependencies - run: npm install + run: npm ci - name: Analyze issue id: issue-analysis run: echo $ISSUE_BODY | ./tools/analyze_issue.mjs >> $GITHUB_OUTPUT diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 0861ee19..233f42e2 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -25,7 +25,7 @@ jobs: with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Install dependencies - run: npm install + run: npm ci - name: Build env: PUBLISH: 1 @@ -34,7 +34,7 @@ jobs: - name: Version docs working-directory: ./website run: | - npm install + npm ci npm run docusaurus docs:version $(jq -r .version ../packages/puppeteer/package.json) npm run archive - name: Re-build docs after versioning @@ -44,6 +44,7 @@ jobs: npm run docs - name: Format run: npm run format + # Release-please does not update the package-lock - name: Install to refresh package-lock run: npm install - name: Commit diff --git a/tools/update_chrome_revision.mjs b/tools/update_chrome_revision.mjs index 59fed665..f21ea4b6 100644 --- a/tools/update_chrome_revision.mjs +++ b/tools/update_chrome_revision.mjs @@ -110,23 +110,29 @@ async function updateDevToolsProtocolVersion(revision) { ); } -async function updateVersionFileLastMaintained(currentVersion, updateVersion) { +async function updateVersionFileLastMaintained(oldVersion, newVersion) { const versions = [...versionsPerRelease.keys()]; - if (versions.indexOf(updateVersion) !== -1) { + if (versions.indexOf(newVersion) !== -1) { return; } // If we have manually rolled Chrome but not yet released // We will have NEXT as value in the Map - if (versionsPerRelease.get(currentVersion) === 'NEXT') { - await replaceInFile('./versions.js', currentVersion, updateVersion); - } else { - await replaceInFile( - './versions.js', - VERSIONS_PER_RELEASE_COMMENT, - `${VERSIONS_PER_RELEASE_COMMENT}\n ['${version}', 'NEXT'],` - ); + if (versionsPerRelease.get(oldVersion) === 'NEXT') { + await replaceInFile('./versions.js', oldVersion, newVersion); + return; + } + await replaceInFile( + './versions.js', + VERSIONS_PER_RELEASE_COMMENT, + `${VERSIONS_PER_RELEASE_COMMENT}\n ['${version}', 'NEXT'],` + ); + + const oldSemVer = new SemVer(oldVersion, true); + const newSemVer = new SemVer(newVersion, true); + + if (newSemVer.compareMain(oldSemVer) !== 0) { const lastMaintainedIndex = versions.indexOf(lastMaintainedChromeVersion); const nextMaintainedVersion = versions[lastMaintainedIndex - 1];