From 263ec7fcc5c33cdac5978b6512e85dfd67b8b894 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 21:00:06 +0000 Subject: [PATCH 01/10] chore: bump @npmcli/template-oss from 4.20.0 to 4.21.1 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 4.20.0 to 4.21.1. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v4.20.0...v4.21.1) --- updated-dependencies: - dependency-name: @npmcli/template-oss dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d0a1d9..5fca6b0 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "license": "MIT", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.20.0", + "@npmcli/template-oss": "4.21.1", "tap": "^16.3.0" }, "tap": { From 9868736aafaff8bbe55902f3fe854cf2f4c706fb Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 4 Dec 2023 12:12:15 -0700 Subject: [PATCH 02/10] chore: postinstall for dependabot template-oss PR --- .github/actions/create-check/action.yml | 52 +++ .github/actions/install-latest-npm/action.yml | 58 +++ .github/workflows/audit.yml | 33 +- .github/workflows/ci-release.yml | 192 ++------- .github/workflows/ci.yml | 82 +--- .github/workflows/post-dependabot.yml | 33 +- .github/workflows/pull-request.yml | 39 +- .github/workflows/release-integration.yml | 76 ++++ .github/workflows/release.yml | 388 ++++++------------ package.json | 2 +- release-please-config.json | 20 +- 11 files changed, 363 insertions(+), 612 deletions(-) create mode 100644 .github/actions/create-check/action.yml create mode 100644 .github/actions/install-latest-npm/action.yml create mode 100644 .github/workflows/release-integration.yml diff --git a/.github/actions/create-check/action.yml b/.github/actions/create-check/action.yml new file mode 100644 index 0000000..0e7d6ce --- /dev/null +++ b/.github/actions/create-check/action.yml @@ -0,0 +1,52 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: 'Create Check' +inputs: + name: + required: true + token: + required: true + sha: + required: true + check-name: + default: '' +outputs: + check-id: + value: ${{ steps.create-check.outputs.check_id }} +runs: + using: "composite" + steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + id: workflow + env: + JOB_NAME: "${{ inputs.name }}" + SHA: "${{ inputs.sha }}" + with: + result-encoding: string + script: | + const { repo: { owner, repo}, runId, serverUrl } = context + const { JOB_NAME, SHA } = process.env + + const job = await github.rest.actions.listJobsForWorkflowRun({ + owner, + repo, + run_id: runId, + per_page: 100 + }).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME))) + + return [ + `This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`, + 'Run logs:', + job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`, + ].join(' ') + - name: Create Check + uses: LouisBrunner/checks-action@v1.6.0 + id: create-check + with: + token: ${{ inputs.token }} + sha: ${{ inputs.sha }} + status: in_progress + name: ${{ inputs.check-name || inputs.name }} + output: | + {"summary":"${{ steps.workflow.outputs.result }}"} diff --git a/.github/actions/install-latest-npm/action.yml b/.github/actions/install-latest-npm/action.yml new file mode 100644 index 0000000..8339dbf --- /dev/null +++ b/.github/actions/install-latest-npm/action.yml @@ -0,0 +1,58 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: 'Install Latest npm' +description: 'Install the latest version of npm compatible with the Node version' +inputs: + node: + description: 'Current Node version' + required: true +runs: + using: "composite" + steps: + # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows + - name: Update Windows npm + if: | + runner.os == 'Windows' && ( + startsWith(inputs.node, 'v10.') || + startsWith(inputs.node, 'v12.') || + startsWith(inputs.node, 'v14.') + ) + shell: cmd + run: | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz + tar xf npm-7.5.4.tgz + cd package + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz + cd .. + rmdir /s /q package + - name: Install Latest npm + shell: bash + env: + NODE_VERSION: ${{ inputs.node }} + working-directory: ${{ runner.temp }} + run: | + MATCH="" + SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") + + echo "node@$NODE_VERSION" + + for SPEC in ${SPECS[@]}; do + ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') + echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" + + if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then + MATCH=$SPEC + echo "Found compatible version: npm@$MATCH" + break + fi + done + + if [ -z $MATCH ]; then + echo "Could not find a compatible version of npm for node@$NODE_VERSION" + exit 1 + fi + + npm i --prefer-online --no-fund --no-audit -g npm@$MATCH + - name: npm Version + shell: bash + run: npm -v diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 908ae16..fa3163a 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -29,37 +29,10 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund --package-lock - name: Run Production Audit diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 2006738..c21673c 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -27,49 +27,6 @@ jobs: run: shell: bash steps: - - name: Get Workflow Job - uses: actions/github-script@v6 - if: inputs.check-sha - id: check-output - env: - JOB_NAME: "Lint All" - MATRIX_NAME: "" - with: - script: | - const { owner, repo } = context.repo - - const { data } = await github.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id: context.runId, - per_page: 100 - }) - - const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME - const job = data.jobs.find(j => j.name.endsWith(jobName)) - const jobUrl = job?.html_url - - const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` - - let summary = `This check is assosciated with ${shaUrl}\n\n` - - if (jobUrl) { - summary += `For run logs, click here: ${jobUrl}` - } else { - summary += `Run logs could not be found for a job with name: "${jobName}"` - } - - return { summary } - - name: Create Check - uses: LouisBrunner/checks-action@v1.6.0 - id: check - if: inputs.check-sha - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: in_progress - name: Lint All - sha: ${{ inputs.check-sha }} - output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -78,43 +35,24 @@ jobs: run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" + - name: Create Check + id: create-check + if: ${{ inputs.check-sha }} + uses: ./.github/actions/create-check + with: + name: "Lint All" + token: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ inputs.check-sha }} - name: Setup Node uses: actions/setup-node@v3 id: node with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Lint @@ -123,11 +61,11 @@ jobs: run: npm run postlint --ignore-scripts - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 - if: steps.check.outputs.check_id && always() + if: always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} - check_id: ${{ steps.check.outputs.check_id }} + check_id: ${{ steps.create-check.outputs.check-id }} test-all: name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} @@ -158,49 +96,6 @@ jobs: run: shell: ${{ matrix.platform.shell }} steps: - - name: Get Workflow Job - uses: actions/github-script@v6 - if: inputs.check-sha - id: check-output - env: - JOB_NAME: "Test All" - MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" - with: - script: | - const { owner, repo } = context.repo - - const { data } = await github.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id: context.runId, - per_page: 100 - }) - - const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME - const job = data.jobs.find(j => j.name.endsWith(jobName)) - const jobUrl = job?.html_url - - const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` - - let summary = `This check is assosciated with ${shaUrl}\n\n` - - if (jobUrl) { - summary += `For run logs, click here: ${jobUrl}` - } else { - summary += `Run logs could not be found for a job with name: "${jobName}"` - } - - return { summary } - - name: Create Check - uses: LouisBrunner/checks-action@v1.6.0 - id: check - if: inputs.check-sha - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: in_progress - name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} - sha: ${{ inputs.check-sha }} - output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -209,59 +104,24 @@ jobs: run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" + - name: Create Check + id: create-check + if: ${{ inputs.check-sha }} + uses: ./.github/actions/create-check + with: + name: "Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" + token: ${{ secrets.GITHUB_TOKEN }} + sha: ${{ inputs.check-sha }} - name: Setup Node uses: actions/setup-node@v3 id: node with: node-version: ${{ matrix.node-version }} check-latest: contains(matrix.node-version, '.x') - - # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows - - name: Update Windows npm - if: | - matrix.platform.os == 'windows-latest' && ( - startsWith(steps.node.outputs.node-version, 'v10.') || - startsWith(steps.node.outputs.node-version, 'v12.') || - startsWith(steps.node.outputs.node-version, 'v14.') - ) - run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Add Problem Matcher @@ -270,8 +130,8 @@ jobs: run: npm test --ignore-scripts - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 - if: steps.check.outputs.check_id && always() + if: always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} - check_id: ${{ steps.check.outputs.check_id }} + check_id: ${{ steps.create-check.outputs.check-id }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56c6a67..a9b2487 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,37 +33,10 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Lint @@ -112,53 +85,10 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: contains(matrix.node-version, '.x') - - # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows - - name: Update Windows npm - if: | - matrix.platform.os == 'windows-latest' && ( - startsWith(steps.node.outputs.node-version, 'v10.') || - startsWith(steps.node.outputs.node-version, 'v12.') || - startsWith(steps.node.outputs.node-version, 'v14.') - ) - run: | - curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz - tar xf npm-7.5.4.tgz - cd package - node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz - cd .. - rmdir /s /q package - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Add Problem Matcher diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 9a4b761..11a7b7c 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -30,37 +30,10 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Fetch Dependabot Metadata diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3418d4c..0b5789e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,47 +33,18 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Run Commitlint on Commits id: commit continue-on-error: true - run: | - npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }} + run: npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }} - name: Run Commitlint on PR Title if: steps.commit.outcome == 'failure' env: PR_TITLE: ${{ github.event.pull_request.title }} - run: | - echo "$PR_TITLE" | npx --offline commitlint -V + run: echo "$PR_TITLE" | npx --offline commitlint -V diff --git a/.github/workflows/release-integration.yml b/.github/workflows/release-integration.yml new file mode 100644 index 0000000..3663758 --- /dev/null +++ b/.github/workflows/release-integration.yml @@ -0,0 +1,76 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: Release Integration + +on: + workflow_dispatch: + inputs: + releases: + required: true + type: string + description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version' + workflow_call: + inputs: + releases: + required: true + type: string + description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version' + secrets: + PUBLISH_TOKEN: + required: true + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + defaults: + run: + shell: bash + permissions: + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ fromJSON(inputs.releases)[0].tagName }} + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + id: node + with: + node-version: 20.x + check-latest: contains('20.x', '.x') + - name: Install Latest npm + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} + - name: Install Dependencies + run: npm i --ignore-scripts --no-audit --no-fund + - name: Set npm authToken + run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN} + - name: Publish + env: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + run: | + EXIT_CODE=0 + + function each_release { + if npm publish --provenance --tag="$1"; then + echo 0 + else + echo 1 + fi + } + + for release in $(echo '${{ inputs.releases }}' | jq -r '.[] | @base64'); do + PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag) + STATUS=$(each_release "$PUBLISH_TAG") + if [[ "$STATUS" -eq 1 ]]; then + EXIT_CODE=$STATUS + fi + done + + exit $EXIT_CODE diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 175a86d..a05c444 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,11 +3,6 @@ name: Release on: - workflow_dispatch: - inputs: - release-pr: - description: a release PR number to rerun release jobs on - type: string push: branches: - main @@ -21,12 +16,12 @@ jobs: release: outputs: pr: ${{ steps.release.outputs.pr }} - release: ${{ steps.release.outputs.release }} - releases: ${{ steps.release.outputs.releases }} - branch: ${{ steps.release.outputs.pr-branch }} + pr-branch: ${{ steps.release.outputs.pr-branch }} pr-number: ${{ steps.release.outputs.pr-number }} - comment-id: ${{ steps.pr-comment.outputs.result }} - check-id: ${{ steps.check.outputs.check_id }} + pr-sha: ${{ steps.release.outputs.pr-sha }} + releases: ${{ steps.release.outputs.releases }} + comment-id: ${{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }} + check-id: ${{ steps.create-check.outputs.check-id }} name: Release if: github.repository_owner == 'npm' runs-on: ubuntu-latest @@ -46,126 +41,64 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Release Please id: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npx --offline template-oss-release-please "${{ github.ref_name }}" "${{ inputs.release-pr }}" - - name: Post Pull Request Comment + run: npx --offline template-oss-release-please --branch="${{ github.ref_name }}" --backport="" --defaultTag="latest" + - name: Create Release Manager Comment Text if: steps.release.outputs.pr-number uses: actions/github-script@v6 - id: pr-comment - env: - PR_NUMBER: ${{ steps.release.outputs.pr-number }} - REF_NAME: ${{ github.ref_name }} + id: comment-text with: + result-encoding: string script: | - const { REF_NAME, PR_NUMBER: issue_number } = process.env const { runId, repo: { owner, repo } } = context - const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId }) - - let body = '## Release Manager\n\n' - - const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number }) - let commentId = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - - body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Update This Release\n\n` - body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`${REF_NAME}\`. ` - body += `To force CI to update this PR, run this command:\n\n` - body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME} -R ${owner}/${repo} -f release-pr=${issue_number}\n\`\`\`` - - if (commentId) { - await github.rest.issues.updateComment({ owner, repo, comment_id: commentId, body }) - } else { - const { data: comment } = await github.rest.issues.createComment({ owner, repo, issue_number, body }) - commentId = comment?.id - } - - return commentId - - name: Get Workflow Job - uses: actions/github-script@v6 - if: steps.release.outputs.pr-sha - id: check-output - env: - JOB_NAME: "Release" - MATRIX_NAME: "" + return['## Release Manager', `Release workflow run: ${workflow.html_url}`].join('\n\n') + - name: Find Release Manager Comment + uses: peter-evans/find-comment@v2 + if: steps.release.outputs.pr-number + id: found-comment with: - script: | - const { owner, repo } = context.repo - - const { data } = await github.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id: context.runId, - per_page: 100 - }) - - const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME - const job = data.jobs.find(j => j.name.endsWith(jobName)) - const jobUrl = job?.html_url - - const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}` - - let summary = `This check is assosciated with ${shaUrl}\n\n` - - if (jobUrl) { - summary += `For run logs, click here: ${jobUrl}` - } else { - summary += `Run logs could not be found for a job with name: "${jobName}"` - } - - return { summary } + issue-number: ${{ steps.release.outputs.pr-number }} + comment-author: 'github-actions[bot]' + body-includes: '## Release Manager' + - name: Create Release Manager Comment + id: create-comment + if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id + uses: peter-evans/create-or-update-comment@v3 + with: + issue-number: ${{ steps.release.outputs.pr-number }} + body: ${{ steps.comment-text.outputs.result }} + - name: Update Release Manager Comment + id: update-comment + if: steps.release.outputs.pr-number && steps.found-comment.outputs.comment-id + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.found-comment.outputs.comment-id }} + body: ${{ steps.comment-text.outputs.result }} + edit-mode: 'replace' - name: Create Check - uses: LouisBrunner/checks-action@v1.6.0 - id: check + id: create-check + uses: ./.github/actions/create-check if: steps.release.outputs.pr-sha with: + name: "Release" token: ${{ secrets.GITHUB_TOKEN }} - status: in_progress - name: Release sha: ${{ steps.release.outputs.pr-sha }} - output: ${{ steps.check-output.outputs.result }} update: needs: release outputs: sha: ${{ steps.commit.outputs.sha }} - check-id: ${{ steps.check.outputs.check_id }} + check-id: ${{ steps.create-check.outputs.check-id }} name: Update - Release if: github.repository_owner == 'npm' && needs.release.outputs.pr runs-on: ubuntu-latest @@ -177,7 +110,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ needs.release.outputs.branch }} + ref: ${{ needs.release.outputs.pr-branch }} - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" @@ -188,47 +121,27 @@ jobs: with: node-version: 20.x check-latest: contains('20.x', '.x') - - name: Install Latest npm - shell: bash - env: - NODE_VERSION: ${{ steps.node.outputs.node-version }} - run: | - MATCH="" - SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6") - - echo "node@$NODE_VERSION" - - for SPEC in ${SPECS[@]}; do - ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node') - echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)" - - if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then - MATCH=$SPEC - echo "Found compatible version: npm@$MATCH" - break - fi - done - - if [ -z $MATCH ]; then - echo "Could not find a compatible version of npm for node@$NODE_VERSION" - exit 1 - fi - - npm i --prefer-online --no-fund --no-audit -g npm@$MATCH - - - name: npm Version - run: npm -v + uses: ./.github/actions/install-latest-npm + with: + node: ${{ steps.node.outputs.node-version }} - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund + - name: Create Release Manager Checklist Text + id: comment-text + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest" --publish + - name: Append Release Manager Comment + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ needs.release.outputs.comment-id }} + body: ${{ steps.comment-text.outputs.result }} + edit-mode: 'append' - name: Run Post Pull Request Actions env: - RELEASE_PR_NUMBER: ${{ needs.release.outputs.pr-number }} - RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npm exec --offline -- template-oss-release-manager --lockfile=false --publish=true - npm run rp-pull-request --ignore-scripts --if-present + run: npm run rp-pull-request --ignore-scripts --if-present -- --pr="${{ needs.release.outputs.pr-number }}" --commentId="${{ needs.release.outputs.comment-id }}" - name: Commit id: commit env: @@ -237,52 +150,16 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Get Workflow Job - uses: actions/github-script@v6 - if: steps.commit.outputs.sha - id: check-output - env: - JOB_NAME: "Update - Release" - MATRIX_NAME: "" - with: - script: | - const { owner, repo } = context.repo - - const { data } = await github.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id: context.runId, - per_page: 100 - }) - - const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME - const job = data.jobs.find(j => j.name.endsWith(jobName)) - const jobUrl = job?.html_url - - const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}` - - let summary = `This check is assosciated with ${shaUrl}\n\n` - - if (jobUrl) { - summary += `For run logs, click here: ${jobUrl}` - } else { - summary += `Run logs could not be found for a job with name: "${jobName}"` - } - - return { summary } - name: Create Check - uses: LouisBrunner/checks-action@v1.6.0 - id: check - if: steps.commit.outputs.sha + id: create-check + uses: ./.github/actions/create-check with: + name: "Update - Release" + check-name: "Release" token: ${{ secrets.GITHUB_TOKEN }} - status: in_progress - name: Release sha: ${{ steps.commit.outputs.sha }} - output: ${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 - if: needs.release.outputs.check-id && always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} @@ -294,7 +171,7 @@ jobs: if: needs.release.outputs.pr uses: ./.github/workflows/ci-release.yml with: - ref: ${{ needs.release.outputs.branch }} + ref: ${{ needs.release.outputs.pr-branch }} check-sha: ${{ needs.update.outputs.sha }} post-ci: @@ -306,8 +183,8 @@ jobs: run: shell: bash steps: - - name: Get Needs Result - id: needs-result + - name: Get CI Conclusion + id: conclusion run: | result="" if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then @@ -320,14 +197,15 @@ jobs: echo "result=$result" >> $GITHUB_OUTPUT - name: Conclude Check uses: LouisBrunner/checks-action@v1.6.0 - if: needs.update.outputs.check-id && always() with: token: ${{ secrets.GITHUB_TOKEN }} - conclusion: ${{ steps.needs-result.outputs.result }} + conclusion: ${{ steps.conclusion.outputs.result }} check_id: ${{ needs.update.outputs.check-id }} post-release: needs: release + outputs: + comment-id: ${{ steps.create-comment.outputs.comment-id }} name: Post Release - Release if: github.repository_owner == 'npm' && needs.release.outputs.releases runs-on: ubuntu-latest @@ -335,79 +213,54 @@ jobs: run: shell: bash steps: - - name: Create Release PR Comment + - name: Create Release PR Comment Text + id: comment-text uses: actions/github-script@v6 env: RELEASES: ${{ needs.release.outputs.releases }} with: + result-encoding: string script: | const releases = JSON.parse(process.env.RELEASES) const { runId, repo: { owner, repo } } = context const issue_number = releases[0].prNumber - - let body = '## Release Workflow\n\n' - for (const { pkgName, version, url } of releases) { - body += `- \`${pkgName}@${version}\` ${url}\n` - } - - const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number }) - .then(cs => cs.map(c => ({ id: c.id, login: c.user.login, body: c.body }))) - console.log(`Found comments: ${JSON.stringify(comments, null, 2)}`) - const releaseComments = comments.filter(c => c.login === 'github-actions[bot]' && c.body.includes('Release is at')) - - for (const comment of releaseComments) { - console.log(`Release comment: ${JSON.stringify(comment, null, 2)}`) - await github.rest.issues.deleteComment({ owner, repo, comment_id: comment.id }) - } - const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}` - await github.rest.issues.createComment({ - owner, - repo, - issue_number, - body: `${body}- Workflow run: :arrows_counterclockwise: ${runUrl}`, - }) + + return [ + '## Release Workflow\n', + ...releases.map(r => `- \`${r.pkgName}@${r.version}\` ${r.url}`), + `- Workflow run: :arrows_counterclockwise: ${runUrl}`, + ].join('\n') + - name: Create Release PR Comment + id: create-comment + uses: peter-evans/create-or-update-comment@v3 + with: + issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }} + body: ${{ steps.comment-text.outputs.result }} release-integration: needs: release name: Release Integration - if: needs.release.outputs.release - runs-on: ubuntu-latest - defaults: - run: - shell: bash + if: needs.release.outputs.releases + uses: ./.github/workflows/release-integration.yml permissions: - deployments: write id-token: write - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ fromJSON(needs.release.outputs.release).tagName }} - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Install npm@latest - run: | - npm i --prefer-online --no-fund --no-audit -g npm@latest - npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN} - - name: Publish - env: - PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} - run: npm publish --provenance --tag=latest + secrets: + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + with: + releases: ${{ needs.release.outputs.releases }} post-release-integration: - needs: [ release, release-integration ] + needs: [ release, release-integration, post-release ] name: Post Release Integration - Release - if: github.repository_owner == 'npm' && needs.release.outputs.release && always() + if: github.repository_owner == 'npm' && needs.release.outputs.releases && always() runs-on: ubuntu-latest defaults: run: shell: bash steps: - - name: Get Needs Result - id: needs-result + - name: Get Post Release Conclusion + id: conclusion run: | if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then result="x" @@ -417,39 +270,38 @@ jobs: result="white_check_mark" fi echo "result=$result" >> $GITHUB_OUTPUT - - name: Update Release PR Comment + - name: Find Release PR Comment + uses: peter-evans/find-comment@v2 + id: found-comment + with: + issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }} + comment-author: 'github-actions[bot]' + body-includes: '## Release Workflow' + - name: Create Release PR Comment Text + id: comment-text + if: steps.found-comment.outputs.comment-id uses: actions/github-script@v6 env: - PR_NUMBER: ${{ fromJSON(needs.release.outputs.release).prNumber }} - RESULT: ${{ steps.needs-result.outputs.result }} + RESULT: ${{ steps.conclusion.outputs.result }} + BODY: ${{ steps.found-comment.outputs.comment-body }} with: + result-encoding: string script: | - const { PR_NUMBER: issue_number, RESULT } = process.env - const { runId, repo: { owner, repo } } = context - - const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number }) - const updateComment = comments.find(c => - c.user.login === 'github-actions[bot]' && - c.body.startsWith('## Release Workflow\n\n') && - c.body.includes(runId) - ) - - if (updateComment) { - console.log('Found comment to update:', JSON.stringify(updateComment, null, 2)) - let body = updateComment.body.replace(/Workflow run: :[a-z_]+:/, `Workflow run: :${RESULT}:`) - const tagCodeowner = RESULT !== 'white_check_mark' - if (tagCodeowner) { - body += `\n\n:rotating_light:` - body += ` @npm/cli-team: The post-release workflow failed for this release.` - body += ` Manual steps may need to be taken after examining the workflow output` - body += ` from the above workflow run. :rotating_light:` - } - await github.rest.issues.updateComment({ - owner, - repo, - body, - comment_id: updateComment.id, - }) - } else { - console.log('No matching comments found:', JSON.stringify(comments, null, 2)) + const { RESULT, BODY } = process.env + const body = [BODY.replace(/(Workflow run: :)[a-z_]+(:)/, `$1${RESULT}$2`)] + if (RESULT !== 'white_check_mark') { + body.push(':rotating_light::rotating_light::rotating_light:') + body.push([ + '@npm/cli-team: The post-release workflow failed for this release.', + 'Manual steps may need to be taken after examining the workflow output.' + ].join(' ')) + body.push(':rotating_light::rotating_light::rotating_light:') } + return body.join('\n\n').trim() + - name: Update Release PR Comment + if: steps.comment-text.outputs.result + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.found-comment.outputs.comment-id }} + body: ${{ steps.comment-text.outputs.result }} + edit-mode: 'replace' diff --git a/package.json b/package.json index 5fca6b0..771c66e 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.20.0", + "version": "4.21.1", "publish": true } } diff --git a/release-please-config.json b/release-please-config.json index 73d1e35..a14c88c 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,36 +1,42 @@ { - "exclude-packages-from-root": true, "group-pull-request-title-pattern": "chore: release ${version}", "pull-request-title-pattern": "chore: release${component} ${version}", "changelog-sections": [ { "type": "feat", "section": "Features", - "hidden": false + "hidden": false, + "collapse": false }, { "type": "fix", "section": "Bug Fixes", - "hidden": false + "hidden": false, + "collapse": false }, { "type": "docs", "section": "Documentation", - "hidden": false + "hidden": false, + "collapse": false }, { "type": "deps", "section": "Dependencies", - "hidden": false + "hidden": false, + "collapse": false }, { "type": "chore", - "hidden": true + "section": "Chores", + "hidden": false, + "collapse": true } ], "packages": { ".": { "package-name": "" } - } + }, + "prerelease-type": "pre" } From 20fd0e5527bef2d12c7fbd5d76d287c63b8c70ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 20:25:13 +0000 Subject: [PATCH 03/10] chore: bump @npmcli/template-oss from 4.21.1 to 4.21.3 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 4.21.1 to 4.21.3. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v4.21.1...v4.21.3) --- updated-dependencies: - dependency-name: @npmcli/template-oss dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 771c66e..472ce91 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "license": "MIT", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.21.1", + "@npmcli/template-oss": "4.21.3", "tap": "^16.3.0" }, "tap": { From 67ea4ee317e231284b7e2304fc650b847c73ca52 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 6 Dec 2023 17:13:02 -0700 Subject: [PATCH 04/10] chore: postinstall for dependabot template-oss PR --- .github/dependabot.yml | 1 + package.json | 2 +- release-please-config.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 69312df..7ecb4bd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,3 +16,4 @@ updates: prefix-development: chore labels: - "Dependencies" + open-pull-requests-limit: 10 diff --git a/package.json b/package.json index 472ce91..ee5bc5f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.21.1", + "version": "4.21.3", "publish": true } } diff --git a/release-please-config.json b/release-please-config.json index a14c88c..559ef7d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -30,7 +30,7 @@ "type": "chore", "section": "Chores", "hidden": false, - "collapse": true + "collapse": false } ], "packages": { From 04a6747cb709d558c1635b565513eeb7c945c80f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:39:30 +0000 Subject: [PATCH 05/10] chore: bump @npmcli/template-oss from 4.21.3 to 4.21.4 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 4.21.3 to 4.21.4. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v4.21.3...v4.21.4) --- updated-dependencies: - dependency-name: @npmcli/template-oss dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee5bc5f..978b1d8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "license": "MIT", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.21.3", + "@npmcli/template-oss": "4.21.4", "tap": "^16.3.0" }, "tap": { From bec4a576101beb7368a488cfec9a58d29dc310c8 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 20 Apr 2024 14:55:40 -0700 Subject: [PATCH 06/10] chore: postinstall for dependabot template-oss PR --- .commitlintrc.js | 3 ++- .github/workflows/release-integration.yml | 3 ++- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.commitlintrc.js b/.commitlintrc.js index 5b0b1a5..e9c80b9 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -5,6 +5,7 @@ module.exports = { rules: { 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']], 'header-max-length': [2, 'always', 80], - 'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']], + 'subject-case': [0], + 'body-max-line-length': [0], }, } diff --git a/.github/workflows/release-integration.yml b/.github/workflows/release-integration.yml index 3663758..d986e4b 100644 --- a/.github/workflows/release-integration.yml +++ b/.github/workflows/release-integration.yml @@ -54,6 +54,7 @@ jobs: - name: Publish env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + RELEASES: ${{ inputs.releases }} run: | EXIT_CODE=0 @@ -65,7 +66,7 @@ jobs: fi } - for release in $(echo '${{ inputs.releases }}' | jq -r '.[] | @base64'); do + for release in $(echo $RELEASES | jq -r '.[] | @base64'); do PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag) STATUS=$(each_release "$PUBLISH_TAG") if [[ "$STATUS" -eq 1 ]]; then diff --git a/package.json b/package.json index 978b1d8..8d65277 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.21.3", + "version": "4.21.4", "publish": true } } From fecc81fcac91952e75e4c39bd4bc3892cbfc55b3 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 3 May 2024 11:45:37 -0700 Subject: [PATCH 07/10] chore: bump @npmcli/template-oss to 4.22.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d65277..487da77 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "license": "MIT", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.21.4", + "@npmcli/template-oss": "4.22.0", "tap": "^16.3.0" }, "tap": { From 3c7bd8038a5b7ebcd9feee30e1f5e2a22ee06d44 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 3 May 2024 11:45:41 -0700 Subject: [PATCH 08/10] chore: postinstall for dependabot template-oss PR --- .github/actions/create-check/action.yml | 2 +- .github/workflows/audit.yml | 8 +++--- .github/workflows/ci-release.yml | 33 ++++++++++++++++++----- .github/workflows/ci.yml | 33 ++++++++++++++++++----- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/post-dependabot.yml | 8 +++--- .github/workflows/pull-request.yml | 8 +++--- .github/workflows/release-integration.yml | 19 +++++-------- .github/workflows/release.yml | 22 +++++++-------- package.json | 4 +-- release-please-config.json | 15 ++++------- 11 files changed, 92 insertions(+), 62 deletions(-) diff --git a/.github/actions/create-check/action.yml b/.github/actions/create-check/action.yml index 0e7d6ce..aa24a5b 100644 --- a/.github/actions/create-check/action.yml +++ b/.github/actions/create-check/action.yml @@ -17,7 +17,7 @@ runs: using: "composite" steps: - name: Get Workflow Job - uses: actions/github-script@v6 + uses: actions/github-script@v7 id: workflow env: JOB_NAME: "${{ inputs.name }}" diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index fa3163a..a3ae725 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -18,17 +18,17 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index c21673c..ae2532c 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -28,7 +28,7 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} - name: Setup Git User @@ -44,11 +44,11 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ inputs.check-sha }} - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: @@ -80,6 +80,9 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd @@ -91,13 +94,31 @@ jobs: - 18.0.0 - 18.x - 20.x + - 22.x + exclude: + - platform: { name: macOS, os: macos-latest, shell: bash } + node-version: 14.17.0 + - platform: { name: macOS, os: macos-latest, shell: bash } + node-version: 14.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 16.13.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 16.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.0.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} - name: Setup Git User @@ -113,7 +134,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} sha: ${{ inputs.check-sha }} - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9b2487..28dca18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,17 +22,17 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: @@ -57,6 +57,9 @@ jobs: - name: macOS os: macos-latest shell: bash + - name: macOS + os: macos-13 + shell: bash - name: Windows os: windows-latest shell: cmd @@ -68,19 +71,37 @@ jobs: - 18.0.0 - 18.x - 20.x + - 22.x + exclude: + - platform: { name: macOS, os: macos-latest, shell: bash } + node-version: 14.17.0 + - platform: { name: macOS, os: macos-latest, shell: bash } + node-version: 14.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 16.13.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 16.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.0.0 + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 18.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f7e691d..13efe1b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,7 +23,7 @@ jobs: security-events: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 11a7b7c..a7ebe12 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -17,7 +17,7 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} - name: Setup Git User @@ -25,11 +25,11 @@ jobs: git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0b5789e..7dbdfd4 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,7 +20,7 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Git User @@ -28,11 +28,11 @@ jobs: git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: diff --git a/.github/workflows/release-integration.yml b/.github/workflows/release-integration.yml index d986e4b..130578e 100644 --- a/.github/workflows/release-integration.yml +++ b/.github/workflows/release-integration.yml @@ -30,7 +30,7 @@ jobs: id-token: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ fromJSON(inputs.releases)[0].tagName }} - name: Setup Git User @@ -38,11 +38,11 @@ jobs: git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: @@ -58,17 +58,10 @@ jobs: run: | EXIT_CODE=0 - function each_release { - if npm publish --provenance --tag="$1"; then - echo 0 - else - echo 1 - fi - } - for release in $(echo $RELEASES | jq -r '.[] | @base64'); do PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag) - STATUS=$(each_release "$PUBLISH_TAG") + npm publish --provenance --tag="$PUBLISH_TAG" + STATUS=$? if [[ "$STATUS" -eq 1 ]]; then EXIT_CODE=$STATUS fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a05c444..75acebb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,17 +30,17 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Git User run: | git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: @@ -54,7 +54,7 @@ jobs: run: npx --offline template-oss-release-please --branch="${{ github.ref_name }}" --backport="" --defaultTag="latest" - name: Create Release Manager Comment Text if: steps.release.outputs.pr-number - uses: actions/github-script@v6 + uses: actions/github-script@v7 id: comment-text with: result-encoding: string @@ -107,7 +107,7 @@ jobs: shell: bash steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ needs.release.outputs.pr-branch }} @@ -116,11 +116,11 @@ jobs: git config --global user.email "npm-cli+bot@github.com" git config --global user.name "npm CLI robot" - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 id: node with: - node-version: 20.x - check-latest: contains('20.x', '.x') + node-version: 22.x + check-latest: contains('22.x', '.x') - name: Install Latest npm uses: ./.github/actions/install-latest-npm with: @@ -215,7 +215,7 @@ jobs: steps: - name: Create Release PR Comment Text id: comment-text - uses: actions/github-script@v6 + uses: actions/github-script@v7 env: RELEASES: ${{ needs.release.outputs.releases }} with: @@ -280,7 +280,7 @@ jobs: - name: Create Release PR Comment Text id: comment-text if: steps.found-comment.outputs.comment-id - uses: actions/github-script@v6 + uses: actions/github-script@v7 env: RESULT: ${{ steps.conclusion.outputs.result }} BODY: ${{ steps.found-comment.outputs.comment-body }} diff --git a/package.json b/package.json index 487da77..50e4aca 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/npm/json-parse-even-better-errors.git" + "url": "git+https://github.com/npm/json-parse-even-better-errors.git" }, "keywords": [ "JSON", @@ -43,7 +43,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.21.4", + "version": "4.22.0", "publish": true } } diff --git a/release-please-config.json b/release-please-config.json index 559ef7d..a1676b9 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -5,32 +5,27 @@ { "type": "feat", "section": "Features", - "hidden": false, - "collapse": false + "hidden": false }, { "type": "fix", "section": "Bug Fixes", - "hidden": false, - "collapse": false + "hidden": false }, { "type": "docs", "section": "Documentation", - "hidden": false, - "collapse": false + "hidden": false }, { "type": "deps", "section": "Dependencies", - "hidden": false, - "collapse": false + "hidden": false }, { "type": "chore", "section": "Chores", - "hidden": false, - "collapse": false + "hidden": true } ], "packages": { From c45eec2a50477eb7a1d6a89cdf492789268e202a Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 3 May 2024 15:00:48 -0700 Subject: [PATCH 09/10] fix: node 22 behavior --- lib/index.js | 4 +++- test/index.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index c21dd64..3ffdaac 100644 --- a/lib/index.js +++ b/lib/index.js @@ -52,7 +52,9 @@ const parseError = (e, txt, context = 20) => { let errIdx if (badIndexMatch) { errIdx = +badIndexMatch[1] - } else if (msg.match(/^Unexpected end of JSON.*/i)) { + } else /* istanbul ignore next - doesnt happen in Node 22 */ if ( + msg.match(/^Unexpected end of JSON.*/i) + ) { errIdx = txt.length - 1 } diff --git a/test/index.js b/test/index.js index 081096c..f5b99d2 100644 --- a/test/index.js +++ b/test/index.js @@ -171,7 +171,7 @@ t.test('throws SyntaxError for unexpected end of JSON', (t) => { 20: /Unterminated string in JSON at position \d+/, default: /Unexpected end of JSON input/, }, - / while parsing "{\\"foo: bar}"/ + /.* while parsing "{\\"foo: bar}"/ ), code: 'EJSONPARSE', position: getLatestMatchingNode({ 20: 11, default: 10 }), @@ -207,7 +207,7 @@ t.test('SyntaxError with less context (limited start)', (t) => { 20: 'Unterminated string in JSON at position 9', default: 'Unexpected end of JSON input', }, - ' while parsing near "...', + /.* while parsing near "\.\.\./, { 20: '210', default: '3210', @@ -230,7 +230,7 @@ t.test('SyntaxError with less context (limited end)', (t) => { 20: ', "abcde" is not valid JSON', default: ' in JSON at position 0', }, - ' while parsing ', + /.* while parsing .*/, { 20: "'abcd'", default: 'near "ab..."', @@ -247,9 +247,12 @@ t.test('SyntaxError with less context (limited end)', (t) => { t.test('throws for end of input', (t) => { const data = '{"a":1,""' jsonThrows(t, data, 2, { - message: expectMessage('Unexpected end of JSON input while parsing'), + message: expectMessage({ + 22: `Expected ':' after property name in JSON at`, + default: 'Unexpected end of JSON input while parsing', + }), code: 'EJSONPARSE', - position: 8, + position: getLatestMatchingNode({ 22: 9, default: 8 }), name: 'JSONParseError', systemError: SyntaxError, }) From 9355df83b4ce4567711823fc1b40fe63dbeebba5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 18:08:03 -0700 Subject: [PATCH 10/10] chore: release 3.0.2 (#56) :robot: I have created a release *beep* *boop* --- ## [3.0.2](https://github.com/npm/json-parse-even-better-errors/compare/v3.0.1...v3.0.2) (2024-05-04) ### Bug Fixes * [`c45eec2`](https://github.com/npm/json-parse-even-better-errors/commit/c45eec2a50477eb7a1d6a89cdf492789268e202a) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) node 22 behavior (@lukekarrys) ### Chores * [`fecc81f`](https://github.com/npm/json-parse-even-better-errors/commit/fecc81fcac91952e75e4c39bd4bc3892cbfc55b3) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) bump @npmcli/template-oss to 4.22.0 (@lukekarrys) * [`3c7bd80`](https://github.com/npm/json-parse-even-better-errors/commit/3c7bd8038a5b7ebcd9feee30e1f5e2a22ee06d44) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) postinstall for dependabot template-oss PR (@lukekarrys) * [`04a6747`](https://github.com/npm/json-parse-even-better-errors/commit/04a6747cb709d558c1635b565513eeb7c945c80f) [#53](https://github.com/npm/json-parse-even-better-errors/pull/53) bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot]) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d6f5405..e28eff5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.0.1" + ".": "3.0.2" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2b33a..3c45dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [3.0.2](https://github.com/npm/json-parse-even-better-errors/compare/v3.0.1...v3.0.2) (2024-05-04) + +### Bug Fixes + +* [`c45eec2`](https://github.com/npm/json-parse-even-better-errors/commit/c45eec2a50477eb7a1d6a89cdf492789268e202a) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) node 22 behavior (@lukekarrys) + +### Chores + +* [`fecc81f`](https://github.com/npm/json-parse-even-better-errors/commit/fecc81fcac91952e75e4c39bd4bc3892cbfc55b3) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) bump @npmcli/template-oss to 4.22.0 (@lukekarrys) +* [`3c7bd80`](https://github.com/npm/json-parse-even-better-errors/commit/3c7bd8038a5b7ebcd9feee30e1f5e2a22ee06d44) [#54](https://github.com/npm/json-parse-even-better-errors/pull/54) postinstall for dependabot template-oss PR (@lukekarrys) +* [`04a6747`](https://github.com/npm/json-parse-even-better-errors/commit/04a6747cb709d558c1635b565513eeb7c945c80f) [#53](https://github.com/npm/json-parse-even-better-errors/pull/53) bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot]) + ## [3.0.1](https://github.com/npm/json-parse-even-better-errors/compare/v3.0.0...v3.0.1) (2023-11-27) ### Bug Fixes diff --git a/package.json b/package.json index 50e4aca..c7156df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "json-parse-even-better-errors", - "version": "3.0.1", + "version": "3.0.2", "description": "JSON.parse with context information on error", "main": "lib/index.js", "files": [ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy