From f499ac5b4bf907d72421c0eebe3f62074412f40c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:37:22 +0000 Subject: [PATCH 01/11] deps: bump json-parse-even-better-errors from 2.3.1 to 3.0.0 Bumps [json-parse-even-better-errors](https://github.com/npm/json-parse-even-better-errors) from 2.3.1 to 3.0.0. - [Release notes](https://github.com/npm/json-parse-even-better-errors/releases) - [Changelog](https://github.com/npm/json-parse-even-better-errors/blob/latest/CHANGELOG.md) - [Commits](https://github.com/npm/json-parse-even-better-errors/compare/v2.3.1...v3.0.0) --- updated-dependencies: - dependency-name: json-parse-even-better-errors dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f3661c1..0e7e2119 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "glob": "^8.0.1", "handlebars": "^4.7.7", "hosted-git-info": "^5.0.0", - "json-parse-even-better-errors": "^2.3.1", + "json-parse-even-better-errors": "^3.0.0", "just-deep-map-values": "^1.1.1", "just-diff": "^5.0.1", "lodash": "^4.17.21", From eaaf3d9f79ef4979f2495a806bd4f03f35a5d037 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 14:33:43 +0000 Subject: [PATCH 02/11] deps: bump hosted-git-info from 5.1.0 to 6.0.0 Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 5.1.0 to 6.0.0. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v5.1.0...v6.0.0) --- updated-dependencies: - dependency-name: hosted-git-info dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e7e2119..466e38eb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "diff": "^5.0.0", "glob": "^8.0.1", "handlebars": "^4.7.7", - "hosted-git-info": "^5.0.0", + "hosted-git-info": "^6.0.0", "json-parse-even-better-errors": "^3.0.0", "just-deep-map-values": "^1.1.1", "just-diff": "^5.0.1", From 2fef1e81c993646eaf903a7b8999c2bad124111b Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 13 Oct 2022 08:19:21 -0700 Subject: [PATCH 03/11] fix: refactor audit command into a separate file for overriding --- lib/content/_step-audit.yml | 2 ++ lib/content/audit.yml | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 lib/content/_step-audit.yml diff --git a/lib/content/_step-audit.yml b/lib/content/_step-audit.yml new file mode 100644 index 00000000..901f3a64 --- /dev/null +++ b/lib/content/_step-audit.yml @@ -0,0 +1,2 @@ +- name: Run Audit + run: {{ rootNpmPath }} audit diff --git a/lib/content/audit.yml b/lib/content/audit.yml index 17a1343c..77ef4b89 100644 --- a/lib/content/audit.yml +++ b/lib/content/audit.yml @@ -9,5 +9,4 @@ on: jobs: audit: {{> job jobName="Audit Dependencies" jobDepFlags="--package-lock" }} - - name: Run Audit - run: {{ rootNpmPath }} audit + {{> stepAudit }} From 09bcd6486133d4cb9ab5396868de839649de00be Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 13 Oct 2022 10:01:26 -0700 Subject: [PATCH 04/11] fix: remove npmcli/fs dep --- lib/apply/apply-files.js | 2 +- lib/check/check-changelog.js | 5 +++-- lib/check/check-gitignore.js | 5 +++-- lib/util/parser.js | 2 +- package.json | 1 - test/setup.js | 2 +- test/util/has-package.js | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/apply/apply-files.js b/lib/apply/apply-files.js index c8925b9e..af8034a2 100644 --- a/lib/apply/apply-files.js +++ b/lib/apply/apply-files.js @@ -1,4 +1,4 @@ -const fs = require('@npmcli/fs') +const fs = require('fs/promises') const log = require('proc-log') const { rmEach, parseEach } = require('../util/files.js') diff --git a/lib/check/check-changelog.js b/lib/check/check-changelog.js index 7b7871c9..11053aec 100644 --- a/lib/check/check-changelog.js +++ b/lib/check/check-changelog.js @@ -1,4 +1,5 @@ -const fs = require('@npmcli/fs') +const fs = require('fs/promises') +const { existsSync } = require('fs') const { join, relative } = require('path') const run = async ({ root, path }) => { @@ -7,7 +8,7 @@ const run = async ({ root, path }) => { // make this glob for possible matches const changelog = join(path, 'CHANGELOG.md') - if (await fs.exists(changelog)) { + if (existsSync(changelog)) { const content = await fs.readFile(changelog, { encoding: 'utf8' }) const mustStart = /^#\s+Changelog\r?\n\r?\n#/ if (!mustStart.test(content)) { diff --git a/lib/check/check-gitignore.js b/lib/check/check-gitignore.js index 4bd677f0..af4936e5 100644 --- a/lib/check/check-gitignore.js +++ b/lib/check/check-gitignore.js @@ -1,6 +1,7 @@ const log = require('proc-log') const { resolve, relative, basename } = require('path') -const fs = require('@npmcli/fs') +const fs = require('fs/promises') +const { existsSync } = require('fs') const git = require('@npmcli/git') const NAME = 'check-gitignore' @@ -17,7 +18,7 @@ const run = async ({ root, path, config }) => { // use the root to detect a git repo but the project directory (path) for the // ignore check const ignoreFile = resolve(path, '.gitignore') - if (!await git.is({ cwd: root }) || !await fs.exists(ignoreFile)) { + if (!await git.is({ cwd: root }) || !existsSync(ignoreFile)) { log.verbose(NAME, 'no git or no gitignore') return null } diff --git a/lib/util/parser.js b/lib/util/parser.js index 861da7b5..7f1f1432 100644 --- a/lib/util/parser.js +++ b/lib/util/parser.js @@ -1,4 +1,4 @@ -const fs = require('@npmcli/fs') +const fs = require('fs/promises') const { basename, extname, dirname } = require('path') const yaml = require('yaml') const NpmPackageJson = require('@npmcli/package-json') diff --git a/package.json b/package.json index 466e38eb..1ae5a542 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "@commitlint/cli": "^17.1.1", "@commitlint/config-conventional": "^17.1.0", "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/fs": "^2.0.1", "@npmcli/git": "^3.0.0", "@npmcli/map-workspaces": "^2.0.2", "@npmcli/package-json": "^2.0.0", diff --git a/test/setup.js b/test/setup.js index 88938dbb..5885f28c 100644 --- a/test/setup.js +++ b/test/setup.js @@ -1,7 +1,7 @@ const t = require('tap') const { join, resolve, posix } = require('path') const { merge, defaults, escapeRegExp: esc } = require('lodash') -const fs = require('@npmcli/fs') +const fs = require('fs/promises') const Git = require('@npmcli/git') const localeCompare = require('@isaacs/string-locale-compare')('en') const npa = require('npm-package-arg') diff --git a/test/util/has-package.js b/test/util/has-package.js index 24bb87a3..1356a441 100644 --- a/test/util/has-package.js +++ b/test/util/has-package.js @@ -1,4 +1,4 @@ -const fs = require('@npmcli/fs') +const fs = require('fs/promises') const t = require('tap') const path = require('path') const hasPackage = require('../../lib/util/has-package.js') From 2175b67268e56f8e1d2ceb1892d61c378883f606 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 13 Oct 2022 17:55:54 -0700 Subject: [PATCH 05/11] feat: add workflow dispatch to rerun release ci --- .github/workflows/ci-release.yml | 80 ++- .github/workflows/release.yml | 93 +++- bin/release-please.js | 3 +- lib/content/_step-checks.yml | 42 +- lib/content/release.yml | 15 +- lib/release-please/index.js | 33 +- lib/util/has-package.js | 6 +- .../test/apply/source-snapshots.js.test.cjs | 519 +++++++++++++++--- test/util/has-package.js | 1 + 9 files changed, 668 insertions(+), 124 deletions(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 9cc6b283..6dad88c5 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -21,6 +21,39 @@ jobs: run: shell: bash steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -30,12 +63,7 @@ jobs: status: in_progress name: Lint All sha: ${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -94,6 +122,39 @@ jobs: run: shell: ${{ matrix.platform.shell }} steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -103,12 +164,7 @@ jobs: status: in_progress name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} sha: ${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ed38659..2f7dee08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,7 @@ name: Release on: + workflow_dispatch: push: branches: - main @@ -51,17 +52,19 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - npx --offline template-oss-release-please ${{ github.ref_name }} + npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }} - name: Post Pull Request Comment 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 }} with: script: | + const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } - const issue = { ...repo, issue_number: process.env.PR_NUMBER } + const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) @@ -70,7 +73,11 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - body += `- Release workflow run: ${workflow.html_url}` + body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n` + body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. ` + body += `To force CI to rerun, run this command:\n\n` + body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\`` + if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { @@ -79,6 +86,39 @@ jobs: } return commentId + - name: Get Workflow Job + uses: actions/github-script@v6 + if: steps.release.outputs.pr-number + id: check-output + env: + JOB_NAME: "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.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 } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check @@ -88,12 +128,7 @@ jobs: status: in_progress name: Release sha: ${{ steps.release.outputs.pr-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: ${{ steps.check-output.outputs.result }} update: needs: release @@ -142,6 +177,39 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -151,12 +219,7 @@ jobs: status: in_progress name: Release sha: ${{ steps.commit.outputs.sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: ${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() diff --git a/bin/release-please.js b/bin/release-please.js index 7fd9d153..b7189fdd 100755 --- a/bin/release-please.js +++ b/bin/release-please.js @@ -4,7 +4,7 @@ const core = require('@actions/core') const main = require('../lib/release-please/index.js') const dryRun = !process.env.CI -const [branch] = process.argv.slice(2) +const [branch, eventName] = process.argv.slice(2) const debugPr = (val) => { if (dryRun) { @@ -33,6 +33,7 @@ main({ repo: process.env.GITHUB_REPOSITORY, dryRun, branch, + force: eventName === 'workflow_dispatch', }).then(({ pr, release, releases }) => { if (pr) { debugPr(pr) diff --git a/lib/content/_step-checks.yml b/lib/content/_step-checks.yml index ef89381a..b1bf08c4 100644 --- a/lib/content/_step-checks.yml +++ b/lib/content/_step-checks.yml @@ -1,3 +1,38 @@ +{{#if jobCheck.sha}} +- name: Get Workflow Job + uses: actions/github-script@v6 + {{#if jobCheck.if}}if: {{ jobCheck.if }}{{/if}} + id: check-output + env: + JOB_NAME: "{{#if jobName}}{{ jobName }}{{else}}{{ jobCheck.name }}{{/if}}" + MATRIX_NAME: "{{#if jobIsMatrix}} - $\{{ matrix.platform.name }} - $\{{ matrix.node-version }}{{/if}}" + 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/{{ jobCheck.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 } +{{/if}} - name: {{#if jobCheck.sha}}Create{{else}}Conclude{{/if}} Check uses: LouisBrunner/checks-action@v1.3.1 {{#if jobCheck.sha}} @@ -12,12 +47,7 @@ status: {{#if jobCheck.status}}{{ jobCheck.status }}{{else}}in_progress{{/if}} name: {{#if jobCheck.name}}{{ jobCheck.name }}{{else}}{{ jobName }}{{/if}}{{#if jobIsMatrix}} - $\{{ matrix.platform.name }} - $\{{ matrix.node-version }}{{/if}} sha: {{ jobCheck.sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: $\{{ steps.check-output.outputs.result }} {{else}} conclusion: {{#if jobCheck.status}}{{ jobCheck.status }}{{else}}$\{{ job.status }}{{/if}} check_id: {{#if jobCheck.id}}{{ jobCheck.id }}{{else}}$\{{ steps.check.outputs.check_id }}{{/if}} diff --git a/lib/content/release.yml b/lib/content/release.yml index a6f51632..8927adbe 100644 --- a/lib/content/release.yml +++ b/lib/content/release.yml @@ -1,6 +1,7 @@ name: Release on: + workflow_dispatch: push: branches: {{#each branches}} @@ -31,17 +32,19 @@ jobs: env: GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }} run: | - {{ rootNpxPath }} --offline template-oss-release-please $\{{ github.ref_name }} + {{ rootNpxPath }} --offline template-oss-release-please $\{{ github.ref_name }} $\{{ github.event_name }} - name: Post Pull Request Comment 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 }} with: script: | + const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } - const issue = { ...repo, issue_number: process.env.PR_NUMBER } + const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) @@ -50,7 +53,11 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - body += `- Release workflow run: ${workflow.html_url}` + body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n` + body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. ` + body += `To force CI to rerun, run this command:\n\n` + body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\`` + if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { @@ -87,7 +94,7 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" - {{> stepChecks jobCheck=(obj sha="${{ steps.commit.outputs.sha }}" name="Release" )}} + {{> stepChecks jobName="Update - Release" jobCheck=(obj sha="${{ steps.commit.outputs.sha }}" name="Release" )}} {{> stepChecks jobCheck=(obj id="${{ needs.release.outputs.check-id }}" )}} ci: diff --git a/lib/release-please/index.js b/lib/release-please/index.js index ba8112fd..d16797b3 100644 --- a/lib/release-please/index.js +++ b/lib/release-please/index.js @@ -9,7 +9,7 @@ RP.registerChangelogNotes('default', (o) => new ChangelogNotes(o)) RP.registerVersioningStrategy('default', (o) => new Version(o)) RP.registerPlugin('node-workspace', (o) => new NodeWs(o.github, o.targetBranch, o.repositoryConfig)) -const main = async ({ repo: fullRepo, token, dryRun, branch }) => { +const main = async ({ repo: fullRepo, token, dryRun, branch, force }) => { if (!token) { throw new Error('Token is required') } @@ -37,11 +37,36 @@ const main = async ({ repo: fullRepo, token, dryRun, branch }) => { Object.fromEntries(manifestOverrides) ) - const pullRequests = await (dryRun ? manifest.buildPullRequests() : manifest.createPullRequests()) - const allReleases = await (dryRun ? manifest.buildReleases() : manifest.createReleases()) + let pullRequests = [] + let allReleases = [] + if (force) { + // If we are forcing the release CI to run again, then we get + // the release PR from the repo and return it, which will trigger + // the rest of the steps in the workflow to run + const prNumber = await github.octokit.issues.listForRepo({ + owner, + repo, + labels: 'autorelease: pending', + per_page: 1, + }).then(res => res.data[0]?.number) + if (prNumber) { + pullRequests = await github.octokit.pulls.get({ + owner, + repo, + pull_number: prNumber, + }).then(res => [{ + ...res.data, + headBranchName: res.data.head.ref, + updates: [], + }]) + } + } else { + pullRequests = await (dryRun ? manifest.buildPullRequests() : manifest.createPullRequests()) + allReleases = await (dryRun ? manifest.buildReleases() : manifest.createReleases()) + } // We only ever get a single pull request with our current release-please settings - const rootPr = pullRequests.filter(Boolean)[0] + const rootPr = pullRequests.filter(Boolean)?.[0] if (rootPr?.number) { const commits = await github.octokit.paginate(github.octokit.rest.pulls.listCommits, { owner: github.repository.owner, diff --git a/lib/util/has-package.js b/lib/util/has-package.js index 3006c999..00794924 100644 --- a/lib/util/has-package.js +++ b/lib/util/has-package.js @@ -1,7 +1,7 @@ const semver = require('semver') const npa = require('npm-package-arg') const { has } = require('lodash') -const { join } = require('path') +const { join, extname } = require('path') const { name: NAME } = require('../../package.json') const installLocations = [ @@ -31,6 +31,10 @@ const getSpecVersion = (spec, where) => { const pkg = require(join(arg.fetchSpec, 'package.json')) return new semver.SemVer(pkg.version) } + case 'file': { + // allows this repo to be installed as a tarball for testing + return extname(arg.fetchSpec) === '.tgz' + } case 'git': { // allow installing only this project from git to test in other projects return arg.name === NAME diff --git a/tap-snapshots/test/apply/source-snapshots.js.test.cjs b/tap-snapshots/test/apply/source-snapshots.js.test.cjs index 3fe3f0a3..b3fbb789 100644 --- a/tap-snapshots/test/apply/source-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/source-snapshots.js.test.cjs @@ -228,6 +228,39 @@ jobs: run: shell: bash steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -237,12 +270,7 @@ jobs: status: in_progress name: Lint All sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -301,6 +329,39 @@ jobs: run: shell: \${{ matrix.platform.shell }} steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -310,12 +371,7 @@ jobs: status: in_progress name: Test All - \${{ matrix.platform.name }} - \${{ matrix.node-version }} sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -743,6 +799,7 @@ jobs: name: Release on: + workflow_dispatch: push: branches: - main @@ -791,17 +848,19 @@ jobs: env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npx --offline template-oss-release-please \${{ github.ref_name }} + npx --offline template-oss-release-please \${{ github.ref_name }} \${{ github.event_name }} - name: Post Pull Request Comment 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 }} with: script: | + const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } - const issue = { ...repo, issue_number: process.env.PR_NUMBER } + const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) @@ -810,7 +869,11 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - body += \`- Release workflow run: \${workflow.html_url}\` + body += \`Release workflow run: \${workflow.html_url}/n/n#### Force CI to Rerun for This Release/n/n\` + body += \`This PR will be updated and CI will run for every non-/\`chore:/\` commit that is pushed to /\`main/\`. \` + body += \`To force CI to rerun, run this command:/n/n\` + body += \`/\`/\`/\`/ngh workflow run release.yml -r \${REF_NAME}/n/\`/\`/\`\` + if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { @@ -819,6 +882,39 @@ jobs: } return commentId + - name: Get Workflow Job + uses: actions/github-script@v6 + if: steps.release.outputs.pr-number + id: check-output + env: + JOB_NAME: "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.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 } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check @@ -828,12 +924,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.release.outputs.pr-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} update: needs: release @@ -882,6 +973,39 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -891,12 +1015,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.commit.outputs.sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() @@ -1704,6 +1823,39 @@ jobs: run: shell: bash steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -1713,12 +1865,7 @@ jobs: status: in_progress name: Lint All sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -1777,6 +1924,39 @@ jobs: run: shell: \${{ matrix.platform.shell }} steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -1786,12 +1966,7 @@ jobs: status: in_progress name: Test All - \${{ matrix.platform.name }} - \${{ matrix.node-version }} sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -2225,6 +2400,7 @@ jobs: name: Release on: + workflow_dispatch: push: branches: - main @@ -2273,17 +2449,19 @@ jobs: env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npx --offline template-oss-release-please \${{ github.ref_name }} + npx --offline template-oss-release-please \${{ github.ref_name }} \${{ github.event_name }} - name: Post Pull Request Comment 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 }} with: script: | + const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } - const issue = { ...repo, issue_number: process.env.PR_NUMBER } + const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) @@ -2292,7 +2470,11 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - body += \`- Release workflow run: \${workflow.html_url}\` + body += \`Release workflow run: \${workflow.html_url}/n/n#### Force CI to Rerun for This Release/n/n\` + body += \`This PR will be updated and CI will run for every non-/\`chore:/\` commit that is pushed to /\`main/\`. \` + body += \`To force CI to rerun, run this command:/n/n\` + body += \`/\`/\`/\`/ngh workflow run release.yml -r \${REF_NAME}/n/\`/\`/\`\` + if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { @@ -2301,6 +2483,39 @@ jobs: } return commentId + - name: Get Workflow Job + uses: actions/github-script@v6 + if: steps.release.outputs.pr-number + id: check-output + env: + JOB_NAME: "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.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 } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check @@ -2310,12 +2525,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.release.outputs.pr-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} update: needs: release @@ -2364,6 +2574,39 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -2373,12 +2616,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.commit.outputs.sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() @@ -3188,6 +3426,39 @@ jobs: run: shell: bash steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -3197,12 +3468,7 @@ jobs: status: in_progress name: Lint All sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -3261,6 +3527,39 @@ jobs: run: shell: \${{ matrix.platform.shell }} steps: + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -3270,12 +3569,7 @@ jobs: status: in_progress name: Test All - \${{ matrix.platform.name }} - \${{ matrix.node-version }} sha: \${{ inputs.check-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 with: @@ -3451,6 +3745,7 @@ jobs: name: Release on: + workflow_dispatch: push: branches: - main @@ -3499,17 +3794,19 @@ jobs: env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} run: | - npx --offline template-oss-release-please \${{ github.ref_name }} + npx --offline template-oss-release-please \${{ github.ref_name }} \${{ github.event_name }} - name: Post Pull Request Comment 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 }} with: script: | + const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } - const issue = { ...repo, issue_number: process.env.PR_NUMBER } + const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) @@ -3518,7 +3815,11 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id - body += \`- Release workflow run: \${workflow.html_url}\` + body += \`Release workflow run: \${workflow.html_url}/n/n#### Force CI to Rerun for This Release/n/n\` + body += \`This PR will be updated and CI will run for every non-/\`chore:/\` commit that is pushed to /\`main/\`. \` + body += \`To force CI to rerun, run this command:/n/n\` + body += \`/\`/\`/\`/ngh workflow run release.yml -r \${REF_NAME}/n/\`/\`/\`\` + if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { @@ -3527,6 +3828,39 @@ jobs: } return commentId + - name: Get Workflow Job + uses: actions/github-script@v6 + if: steps.release.outputs.pr-number + id: check-output + env: + JOB_NAME: "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.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 } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check @@ -3536,12 +3870,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.release.outputs.pr-sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} update: needs: release @@ -3590,6 +3919,39 @@ jobs: git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Get Workflow Job + uses: actions/github-script@v6 + + 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.3.1 id: check @@ -3599,12 +3961,7 @@ jobs: status: in_progress name: Release sha: \${{ steps.commit.outputs.sha }} - # XXX: this does not work when using the default GITHUB_TOKEN. - # Instead we post the main job url to the PR as a comment which - # will link to all the other checks. To work around this we would - # need to create a GitHub that would create on-demand tokens. - # https://github.com/LouisBrunner/checks-action/issues/18 - # details_url: + output: \${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() diff --git a/test/util/has-package.js b/test/util/has-package.js index 1356a441..08921091 100644 --- a/test/util/has-package.js +++ b/test/util/has-package.js @@ -23,6 +23,7 @@ const checks = [ [{ a: 'npm/cli#abc' }, 'a', false], [{ [NAME]: 'npm/cli#abc' }, NAME, true], [{ a: 'https://test.com/npm/cli.tgz' }, 'a', false], + [{ a: 'file:../path/to/cli.tgz' }, 'a', true], [{ a: '^1.0.0' }, 'a@sometag', false], ] From faf1ba0bd465d8ac118c61a412e7a68f795d016c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:45:23 -0700 Subject: [PATCH 06/11] deps: bump @npmcli/package-json from 2.0.0 to 3.0.0 (#238) Bumps [@npmcli/package-json](https://github.com/npm/package-json) from 2.0.0 to 3.0.0. - [Release notes](https://github.com/npm/package-json/releases) - [Changelog](https://github.com/npm/package-json/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/package-json/compare/v2.0.0...v3.0.0) --- updated-dependencies: - dependency-name: "@npmcli/package-json" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ae5a542..1db87d9d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/git": "^3.0.0", "@npmcli/map-workspaces": "^2.0.2", - "@npmcli/package-json": "^2.0.0", + "@npmcli/package-json": "^3.0.0", "@octokit/rest": "^19.0.4", "diff": "^5.0.0", "glob": "^8.0.1", From ac0d052a8ce292e4f910cbce7122d9d25981897f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:45:30 -0700 Subject: [PATCH 07/11] chore: bump @npmcli/eslint-config from 3.1.0 to 4.0.0 (#239) Bumps [@npmcli/eslint-config](https://github.com/npm/eslint-config) from 3.1.0 to 4.0.0. - [Release notes](https://github.com/npm/eslint-config/releases) - [Changelog](https://github.com/npm/eslint-config/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/eslint-config/compare/v3.1.0...v4.0.0) --- updated-dependencies: - dependency-name: "@npmcli/eslint-config" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1db87d9d..b2bfb1f1 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "lib/" ], "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^4.0.0", "@npmcli/template-oss": "file:./", "tap": "^16.0.0" }, From 179f02aa170671466df8f11656f64858f3c20b25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:45:37 -0700 Subject: [PATCH 08/11] deps: bump proc-log from 2.0.1 to 3.0.0 (#240) Bumps [proc-log](https://github.com/npm/proc-log) from 2.0.1 to 3.0.0. - [Release notes](https://github.com/npm/proc-log/releases) - [Changelog](https://github.com/npm/proc-log/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/proc-log/compare/v2.0.1...v3.0.0) --- updated-dependencies: - dependency-name: proc-log dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2bfb1f1..89ee87e7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "just-diff": "^5.0.1", "lodash": "^4.17.21", "npm-package-arg": "^9.0.1", - "proc-log": "^2.0.0", + "proc-log": "^3.0.0", "release-please": "npm:@npmcli/release-please@^14.2.6", "semver": "^7.3.5", "yaml": "^2.1.1" From 243a23f829b07530c5245096431d6776cf27e20b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:40:51 -0700 Subject: [PATCH 09/11] deps: bump @npmcli/map-workspaces from 2.0.4 to 3.0.0 (#241) Bumps [@npmcli/map-workspaces](https://github.com/npm/map-workspaces) from 2.0.4 to 3.0.0. - [Release notes](https://github.com/npm/map-workspaces/releases) - [Changelog](https://github.com/npm/map-workspaces/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/map-workspaces/compare/v2.0.4...v3.0.0) --- updated-dependencies: - dependency-name: "@npmcli/map-workspaces" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89ee87e7..872b33ef 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@commitlint/config-conventional": "^17.1.0", "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/git": "^3.0.0", - "@npmcli/map-workspaces": "^2.0.2", + "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", "@octokit/rest": "^19.0.4", "diff": "^5.0.0", From 47eae35c2fe41b5445f7404fe7b6ce1eb6d97e40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 14:12:27 -0700 Subject: [PATCH 10/11] deps: bump @npmcli/git from 3.0.2 to 4.0.0 (#242) Bumps [@npmcli/git](https://github.com/npm/git) from 3.0.2 to 4.0.0. - [Release notes](https://github.com/npm/git/releases) - [Changelog](https://github.com/npm/git/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/git/compare/v3.0.2...v4.0.0) --- updated-dependencies: - dependency-name: "@npmcli/git" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 872b33ef..a940b8a8 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@commitlint/cli": "^17.1.1", "@commitlint/config-conventional": "^17.1.0", "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/git": "^3.0.0", + "@npmcli/git": "^4.0.0", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", "@octokit/rest": "^19.0.4", From 844092742836cd09d9ac50bf5e8e1b2425b50711 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:05:50 -0700 Subject: [PATCH 11/11] chore: release 4.6.0 (#232) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ package.json | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e91ae90f..fd087344 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.5.1" + ".": "4.6.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dc1b884..4831d280 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## [4.6.0](https://github.com/npm/template-oss/compare/v4.5.1...v4.6.0) (2022-10-14) + +### Features + +* [`2175b67`](https://github.com/npm/template-oss/commit/2175b67268e56f8e1d2ceb1892d61c378883f606) [#237](https://github.com/npm/template-oss/pull/237) add workflow dispatch to rerun release ci (@lukekarrys) + +### Bug Fixes + +* [`09bcd64`](https://github.com/npm/template-oss/commit/09bcd6486133d4cb9ab5396868de839649de00be) [#236](https://github.com/npm/template-oss/pull/236) remove npmcli/fs dep (@lukekarrys) +* [`2fef1e8`](https://github.com/npm/template-oss/commit/2fef1e81c993646eaf903a7b8999c2bad124111b) [#235](https://github.com/npm/template-oss/pull/235) refactor audit command into a separate file for overriding (@lukekarrys) + +### Dependencies + +* [`47eae35`](https://github.com/npm/template-oss/commit/47eae35c2fe41b5445f7404fe7b6ce1eb6d97e40) [#242](https://github.com/npm/template-oss/pull/242) bump @npmcli/git from 3.0.2 to 4.0.0 (#242) +* [`243a23f`](https://github.com/npm/template-oss/commit/243a23f829b07530c5245096431d6776cf27e20b) [#241](https://github.com/npm/template-oss/pull/241) bump @npmcli/map-workspaces from 2.0.4 to 3.0.0 (#241) +* [`179f02a`](https://github.com/npm/template-oss/commit/179f02aa170671466df8f11656f64858f3c20b25) [#240](https://github.com/npm/template-oss/pull/240) bump proc-log from 2.0.1 to 3.0.0 (#240) +* [`faf1ba0`](https://github.com/npm/template-oss/commit/faf1ba0bd465d8ac118c61a412e7a68f795d016c) [#238](https://github.com/npm/template-oss/pull/238) bump @npmcli/package-json from 2.0.0 to 3.0.0 (#238) +* [`eaaf3d9`](https://github.com/npm/template-oss/commit/eaaf3d9f79ef4979f2495a806bd4f03f35a5d037) [#234](https://github.com/npm/template-oss/pull/234) bump hosted-git-info from 5.1.0 to 6.0.0 +* [`f499ac5`](https://github.com/npm/template-oss/commit/f499ac5b4bf907d72421c0eebe3f62074412f40c) [#231](https://github.com/npm/template-oss/pull/231) bump json-parse-even-better-errors from 2.3.1 to 3.0.0 + ## [4.5.1](https://github.com/npm/template-oss/compare/v4.5.0...v4.5.1) (2022-10-08) ### Bug Fixes diff --git a/package.json b/package.json index a940b8a8..99973475 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/template-oss", - "version": "4.5.1", + "version": "4.6.0", "description": "templated files used in npm CLI team oss projects", "main": "lib/content/index.js", "bin": {