@npmcli/template-oss 4.20.0 → 4.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ name: 'Install Latest npm'
2
+ description: 'Install the latest version of npm compatible with the Node version'
3
+ inputs:
4
+ node:
5
+ description: 'Current Node version'
6
+ required: true
7
+ runs:
8
+ using: "composite"
9
+ steps:
10
+ # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
11
+ - name: Update Windows npm
12
+ if: |
13
+ runner.os == 'Windows' && (
14
+ startsWith(inputs.node, 'v10.') ||
15
+ startsWith(inputs.node, 'v12.') ||
16
+ startsWith(inputs.node, 'v14.')
17
+ )
18
+ shell: cmd
19
+ run: |
20
+ curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
21
+ tar xf npm-7.5.4.tgz
22
+ cd package
23
+ node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
24
+ cd ..
25
+ rmdir /s /q package
26
+ - name: Install Latest npm
27
+ shell: bash
28
+ env:
29
+ NODE_VERSION: $\{{ inputs.node }}
30
+ working-directory: $\{{ runner.temp }}
31
+ run: |
32
+ MATCH=""
33
+ SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
34
+
35
+ echo "node@$NODE_VERSION"
36
+
37
+ for SPEC in ${SPECS[@]}; do
38
+ ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
39
+ echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
40
+
41
+ if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
42
+ MATCH=$SPEC
43
+ echo "Found compatible version: npm@$MATCH"
44
+ break
45
+ fi
46
+ done
47
+
48
+ if [ -z $MATCH ]; then
49
+ echo "Could not find a compatible version of npm for node@$NODE_VERSION"
50
+ exit 1
51
+ fi
52
+
53
+ npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
54
+ - name: npm Version
55
+ shell: bash
56
+ run: npm -v
@@ -21,17 +21,29 @@ jobs:
21
21
  lint-all:
22
22
  {{> jobYml
23
23
  jobName="Lint All"
24
- jobCheck=(obj sha="inputs.check-sha")
25
24
  jobCheckout=(obj ref="${{ inputs.ref }}")
25
+ jobCreateCheck=(obj sha="${{ inputs.check-sha }}")
26
26
  }}
27
27
  {{> stepLintYml jobRunFlags=allFlags }}
28
- {{> stepChecksYml jobCheck=true }}
28
+ - name: Conclude Check
29
+ uses: LouisBrunner/checks-action@v1.6.0
30
+ if: always()
31
+ with:
32
+ token: $\{{ secrets.GITHUB_TOKEN }}
33
+ conclusion: $\{{ job.status }}
34
+ check_id: $\{{ steps.create-check.outputs.check-id }}
29
35
 
30
36
  test-all:
31
37
  {{> jobMatrixYml
32
38
  jobName="Test All"
33
- jobCheck=(obj sha="inputs.check-sha")
34
39
  jobCheckout=(obj ref="${{ inputs.ref }}")
40
+ jobCreateCheck=(obj sha="${{ inputs.check-sha }}")
35
41
  }}
36
42
  {{> stepTestYml jobRunFlags=allFlags }}
37
- {{> stepChecksYml jobCheck=true }}
43
+ - name: Conclude Check
44
+ uses: LouisBrunner/checks-action@v1.6.0
45
+ if: always()
46
+ with:
47
+ token: $\{{ secrets.GITHUB_TOKEN }}
48
+ conclusion: $\{{ job.status }}
49
+ check_id: $\{{ steps.create-check.outputs.check-id }}
@@ -12,6 +12,10 @@ const sharedRootAdd = (name) => ({
12
12
  file: 'ci-release-yml.hbs',
13
13
  filter: isPublic,
14
14
  },
15
+ '.github/workflows/release-integration.yml': {
16
+ file: 'release-integration-yml.hbs',
17
+ filter: isPublic,
18
+ },
15
19
  '.release-please-manifest.json': {
16
20
  file: 'release-please-manifest-json.hbs',
17
21
  filter: isPublic,
@@ -48,6 +52,9 @@ const sharedRootAdd = (name) => ({
48
52
  file: 'settings-yml.hbs',
49
53
  filter: (p) => !p.config.isReleaseBranch,
50
54
  },
55
+ // composite actions
56
+ '.github/actions/install-latest-npm/action.yml': 'action-install-latest-npm-yml.hbs',
57
+ '.github/actions/create-check/action.yml': 'action-create-check-yml.hbs',
51
58
  })
52
59
 
53
60
  const sharedRootRm = () => ({
@@ -140,11 +147,15 @@ module.exports = {
140
147
  branches: ['main', 'latest'],
141
148
  // set this to the major version to backport
142
149
  backport: null,
150
+ // this tag will be used for publishing when not prerelease or backport. use
151
+ // {{major}} to have the major version being published replaced in the string.
152
+ defaultPublishTag: 'latest',
143
153
  releaseBranch: 'release/v*',
144
154
  distPaths: [
145
155
  'bin/',
146
156
  'lib/',
147
157
  ],
158
+ allowDistPaths: true,
148
159
  allowPaths: [
149
160
  '/.eslintrc.local.*',
150
161
  '**/.gitignore',
@@ -188,10 +199,10 @@ module.exports = {
188
199
  },
189
200
  allowedPackages: [],
190
201
  changelogTypes: [
191
- { type: 'feat', section: 'Features', hidden: false },
192
- { type: 'fix', section: 'Bug Fixes', hidden: false },
193
- { type: 'docs', section: 'Documentation', hidden: false },
194
- { type: 'deps', section: 'Dependencies', hidden: false },
195
- { type: 'chore', hidden: true },
202
+ { type: 'feat', section: 'Features', hidden: false, collapse: false },
203
+ { type: 'fix', section: 'Bug Fixes', hidden: false, collapse: false },
204
+ { type: 'docs', section: 'Documentation', hidden: false, collapse: false },
205
+ { type: 'deps', section: 'Dependencies', hidden: false, collapse: false },
206
+ { type: 'chore', section: 'Chores', hidden: false, collapse: true },
196
207
  ],
197
208
  }
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "author": "GitHub Inc.",
3
- "files": {{#if typescript}}{{{ del }}}{{else}}{{{ json distPaths }}}{{/if}},
3
+ "files": {{{ json distPaths }}},
4
4
  "type": {{#if esm}}"module"{{else}}{{{ del }}}{{/if}},
5
5
  "scripts": {
6
6
  "lint": "{{#if eslint}}eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"{{else}}echo linting disabled{{/if}}",
7
7
  "postlint": "template-oss-check",
8
8
  "template-oss-apply": "template-oss-apply --force",
9
9
  "lintfix": "{{ localNpmPath }} run lint -- --fix",
10
- "snap": "tap",
11
- "test": "tap",
10
+ "snap": "{{#if typescript}}{{#if tap16}}c8 {{/if}}{{/if}}tap",
11
+ "test": "{{#if typescript}}{{#if tap16}}c8 {{/if}}{{/if}}tap",
12
12
  "posttest": "{{ localNpmPath }} run lint",
13
13
  {{#if isRootMono}}
14
14
  "test-all": "{{ localNpmPath }} run test {{ allFlags }}",
@@ -34,6 +34,16 @@
34
34
  {{#if workspacePaths}}
35
35
  "test-ignore": "^({{ join workspacePaths "|" }})/",
36
36
  {{/if}}
37
+ {{#if typescript}}
38
+ {{#if tap16}}
39
+ "coverage": false,
40
+ "node-arg": [
41
+ "--no-warnings",
42
+ "--loader",
43
+ "ts-node/esm"
44
+ ],
45
+ {{/if}}
46
+ {{/if}}
37
47
  "nyc-arg": {{#if tap18}}{{{ del }}}{{else}}[
38
48
  {{#each workspaceGlobs}}
39
49
  "--exclude",
@@ -14,11 +14,9 @@ jobs:
14
14
  - name: Run Commitlint on Commits
15
15
  id: commit
16
16
  continue-on-error: true
17
- run: |
18
- {{ rootNpxPath }} --offline commitlint -V --from 'origin/$\{{ github.base_ref }}' --to $\{{ github.event.pull_request.head.sha }}
17
+ run: {{ rootNpxPath }} --offline commitlint -V --from 'origin/$\{{ github.base_ref }}' --to $\{{ github.event.pull_request.head.sha }}
19
18
  - name: Run Commitlint on PR Title
20
19
  if: steps.commit.outcome == 'failure'
21
20
  env:
22
21
  PR_TITLE: $\{{ github.event.pull_request.title }}
23
- run: |
24
- echo "$PR_TITLE" | {{ rootNpxPath }} --offline commitlint -V
22
+ run: echo "$PR_TITLE" | {{ rootNpxPath }} --offline commitlint -V
@@ -0,0 +1,24 @@
1
+ name: Release Integration
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ releases:
7
+ required: true
8
+ type: string
9
+ description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
10
+ workflow_call:
11
+ inputs:
12
+ releases:
13
+ required: true
14
+ type: string
15
+ description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
16
+ {{#if publish}}
17
+ secrets:
18
+ PUBLISH_TOKEN:
19
+ required: true
20
+ {{/if}}
21
+
22
+ jobs:
23
+ publish:
24
+ {{> jobReleaseIntegrationYml }}
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "separate-pull-requests": {{{ del }}},
3
- "plugins": {{#if isMonoPublic }}["node-workspace"]{{ else }}{{{ del }}}{{/if}},
4
- "exclude-packages-from-root": true,
3
+ {{#if isMonoPublic }}
4
+ "plugins": [
5
+ "node-workspace",
6
+ "node-workspace-format"
7
+ ],
8
+ {{/if}}
9
+ "exclude-packages-from-root": {{{ del }}},
5
10
  "group-pull-request-title-pattern": "chore: release ${version}",
6
11
  "pull-request-title-pattern": "chore: release${component} ${version}",
7
12
  "changelog-sections": {{{ json changelogTypes }}},
13
+ "prerelease-type": "pre",
8
14
  "packages": {
9
15
  "{{ pkgPath }}": {
10
- {{#if isRoot}}"package-name": ""{{/if}}
16
+ {{#if isRoot}}
17
+ "package-name": ""{{#if workspacePaths}},
18
+ "exclude-paths": {{{ json workspacePaths }}}
19
+ {{/if}}
20
+ {{/if}}
11
21
  }
12
22
  }
13
23
  }
@@ -1,11 +1,6 @@
1
1
  name: Release
2
2
 
3
3
  on:
4
- workflow_dispatch:
5
- inputs:
6
- release-pr:
7
- description: a release PR number to rerun release jobs on
8
- type: string
9
4
  push:
10
5
  branches:
11
6
  {{#each branchPatterns}}
@@ -21,71 +16,85 @@ jobs:
21
16
  release:
22
17
  outputs:
23
18
  pr: $\{{ steps.release.outputs.pr }}
24
- release: $\{{ steps.release.outputs.release }}
25
- releases: $\{{ steps.release.outputs.releases }}
26
- branch: $\{{ steps.release.outputs.pr-branch }}
19
+ pr-branch: $\{{ steps.release.outputs.pr-branch }}
27
20
  pr-number: $\{{ steps.release.outputs.pr-number }}
28
- comment-id: $\{{ steps.pr-comment.outputs.result }}
29
- check-id: $\{{ steps.check.outputs.check_id }}
21
+ pr-sha: $\{{ steps.release.outputs.pr-sha }}
22
+ releases: $\{{ steps.release.outputs.releases }}
23
+ comment-id: $\{{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }}
24
+ check-id: $\{{ steps.create-check.outputs.check-id }}
30
25
  {{> jobYml jobName="Release" }}
31
26
  - name: Release Please
32
27
  id: release
33
28
  env:
34
29
  GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
35
- run: |
36
- {{ rootNpxPath }} --offline template-oss-release-please "$\{{ github.ref_name }}" "$\{{ inputs.release-pr }}"
37
- - name: Post Pull Request Comment
30
+ run: {{ rootNpxPath }} --offline template-oss-release-please --branch="$\{{ github.ref_name }}" --backport="{{ backport }}" --defaultTag="{{ defaultPublishTag }}"
31
+ - name: Create Release Manager Comment Text
38
32
  if: steps.release.outputs.pr-number
39
33
  uses: actions/github-script@v6
40
- id: pr-comment
41
- env:
42
- PR_NUMBER: $\{{ steps.release.outputs.pr-number }}
43
- REF_NAME: $\{{ github.ref_name }}
34
+ id: comment-text
44
35
  with:
36
+ result-encoding: string
45
37
  script: |
46
- const { REF_NAME, PR_NUMBER: issue_number } = process.env
47
38
  const { runId, repo: { owner, repo } } = context
48
-
49
39
  const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId })
50
-
51
- let body = '## Release Manager\n\n'
52
-
53
- const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
54
- let commentId = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
55
-
56
- body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Update This Release\n\n`
57
- body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`${REF_NAME}\`. `
58
- body += `To force CI to update this PR, run this command:\n\n`
59
- body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME} -R ${owner}/${repo} -f release-pr=${issue_number}\n\`\`\``
60
-
61
- if (commentId) {
62
- await github.rest.issues.updateComment({ owner, repo, comment_id: commentId, body })
63
- } else {
64
- const { data: comment } = await github.rest.issues.createComment({ owner, repo, issue_number, body })
65
- commentId = comment?.id
66
- }
67
-
68
- return commentId
69
- {{> stepChecksYml jobCheck=(obj name="Release" sha="steps.release.outputs.pr-sha") }}
40
+ return['## Release Manager', `Release workflow run: ${workflow.html_url}`].join('\n\n')
41
+ - name: Find Release Manager Comment
42
+ uses: peter-evans/find-comment@v2
43
+ if: steps.release.outputs.pr-number
44
+ id: found-comment
45
+ with:
46
+ issue-number: $\{{ steps.release.outputs.pr-number }}
47
+ comment-author: 'github-actions[bot]'
48
+ body-includes: '## Release Manager'
49
+ - name: Create Release Manager Comment
50
+ id: create-comment
51
+ if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id
52
+ uses: peter-evans/create-or-update-comment@v3
53
+ with:
54
+ issue-number: $\{{ steps.release.outputs.pr-number }}
55
+ body: $\{{ steps.comment-text.outputs.result }}
56
+ - name: Update Release Manager Comment
57
+ id: update-comment
58
+ if: steps.release.outputs.pr-number && steps.found-comment.outputs.comment-id
59
+ uses: peter-evans/create-or-update-comment@v3
60
+ with:
61
+ comment-id: $\{{ steps.found-comment.outputs.comment-id }}
62
+ body: $\{{ steps.comment-text.outputs.result }}
63
+ edit-mode: 'replace'
64
+ - name: Create Check
65
+ id: create-check
66
+ uses: ./.github/actions/create-check
67
+ if: steps.release.outputs.pr-sha
68
+ with:
69
+ name: "Release"
70
+ token: $\{{ secrets.GITHUB_TOKEN }}
71
+ sha: $\{{ steps.release.outputs.pr-sha }}
70
72
 
71
73
  update:
72
74
  needs: release
73
75
  outputs:
74
76
  sha: $\{{ steps.commit.outputs.sha }}
75
- check-id: $\{{ steps.check.outputs.check_id }}
77
+ check-id: $\{{ steps.create-check.outputs.check-id }}
76
78
  {{> jobYml
77
79
  jobName="Update - Release"
78
80
  jobIf="needs.release.outputs.pr"
79
- jobCheckout=(obj ref="${{ needs.release.outputs.branch }}" fetch-depth=0)
81
+ jobCheckout=(obj ref="${{ needs.release.outputs.pr-branch }}" fetch-depth=0)
80
82
  }}
83
+ - name: Create Release Manager Checklist Text
84
+ id: comment-text
85
+ env:
86
+ GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
87
+ run: {{ rootNpmPath }} exec --offline -- template-oss-release-manager --pr="$\{{ needs.release.outputs.pr-number }}" --backport="{{ backport }}" --defaultTag="{{ defaultPublishTag }}" {{~#if lockfile}} --lockfile{{/if}} {{~#if publish}} --publish{{/if}}
88
+ - name: Append Release Manager Comment
89
+ uses: peter-evans/create-or-update-comment@v3
90
+ with:
91
+ comment-id: $\{{ needs.release.outputs.comment-id }}
92
+ body: $\{{ steps.comment-text.outputs.result }}
93
+ edit-mode: 'append'
81
94
  - name: Run Post Pull Request Actions
82
95
  env:
83
- RELEASE_PR_NUMBER: $\{{ needs.release.outputs.pr-number }}
84
- RELEASE_COMMENT_ID: $\{{ needs.release.outputs.comment-id }}
85
96
  GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
86
- run: |
87
- {{ rootNpmPath }} exec --offline -- template-oss-release-manager --lockfile={{ lockfile }} --publish={{ publish }}
88
- {{ rootNpmPath }} run rp-pull-request --ignore-scripts {{~#if allFlags}} {{ allFlags }}{{else}} --if-present{{/if}}
97
+ run: {{ rootNpmPath }} run rp-pull-request --ignore-scripts {{~#if allFlags}} {{ allFlags }}{{else}} --if-present{{/if}} -- --pr="$\{{ needs.release.outputs.pr-number }}" --commentId="$\{{ needs.release.outputs.comment-id }}"
89
98
  - name: Commit
90
99
  id: commit
91
100
  env:
@@ -94,8 +103,20 @@ jobs:
94
103
  git commit --all --amend --no-edit || true
95
104
  git push --force-with-lease
96
105
  echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
97
- {{> stepChecksYml jobName="Update - Release" jobCheck=(obj sha="steps.commit.outputs.sha" name="Release" )}}
98
- {{> stepChecksYml jobCheck=(obj id="needs.release.outputs.check-id" )}}
106
+ - name: Create Check
107
+ id: create-check
108
+ uses: ./.github/actions/create-check
109
+ with:
110
+ name: "Update - Release"
111
+ check-name: "Release"
112
+ token: $\{{ secrets.GITHUB_TOKEN }}
113
+ sha: $\{{ steps.commit.outputs.sha }}
114
+ - name: Conclude Check
115
+ uses: LouisBrunner/checks-action@v1.6.0
116
+ with:
117
+ token: $\{{ secrets.GITHUB_TOKEN }}
118
+ conclusion: $\{{ job.status }}
119
+ check_id: $\{{ needs.release.outputs.check-id }}
99
120
 
100
121
  ci:
101
122
  name: CI - Release
@@ -103,14 +124,14 @@ jobs:
103
124
  if: needs.release.outputs.pr
104
125
  uses: ./.github/workflows/ci-release.yml
105
126
  with:
106
- ref: $\{{ needs.release.outputs.branch }}
127
+ ref: $\{{ needs.release.outputs.pr-branch }}
107
128
  check-sha: $\{{ needs.update.outputs.sha }}
108
129
 
109
130
  post-ci:
110
131
  needs: [release, update, ci]
111
132
  {{> jobYml jobName="Post CI - Release" jobIf="needs.release.outputs.pr && always()" jobSkipSetup=true }}
112
- - name: Get Needs Result
113
- id: needs-result
133
+ - name: Get CI Conclusion
134
+ id: conclusion
114
135
  run: |
115
136
  result=""
116
137
  if [[ "$\{{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
@@ -121,55 +142,62 @@ jobs:
121
142
  result="success"
122
143
  fi
123
144
  echo "result=$result" >> $GITHUB_OUTPUT
124
- {{> stepChecksYml jobCheck=(obj id="needs.update.outputs.check-id" status="steps.needs-result.outputs.result") }}
145
+ - name: Conclude Check
146
+ uses: LouisBrunner/checks-action@v1.6.0
147
+ with:
148
+ token: $\{{ secrets.GITHUB_TOKEN }}
149
+ conclusion: $\{{ steps.conclusion.outputs.result }}
150
+ check_id: $\{{ needs.update.outputs.check-id }}
125
151
 
126
152
  post-release:
127
153
  needs: release
154
+ outputs:
155
+ comment-id: $\{{ steps.create-comment.outputs.comment-id }}
128
156
  {{> jobYml jobName="Post Release - Release" jobIf="needs.release.outputs.releases" jobSkipSetup=true }}
129
- - name: Create Release PR Comment
157
+ - name: Create Release PR Comment Text
158
+ id: comment-text
130
159
  uses: actions/github-script@v6
131
160
  env:
132
161
  RELEASES: $\{{ needs.release.outputs.releases }}
133
162
  with:
163
+ result-encoding: string
134
164
  script: |
135
165
  const releases = JSON.parse(process.env.RELEASES)
136
166
  const { runId, repo: { owner, repo } } = context
137
167
  const issue_number = releases[0].prNumber
138
-
139
- let body = '## Release Workflow\n\n'
140
- for (const { pkgName, version, url } of releases) {
141
- body += `- \`${pkgName}@${version}\` ${url}\n`
142
- }
143
-
144
- const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
145
- .then(cs => cs.map(c => ({ id: c.id, login: c.user.login, body: c.body })))
146
- console.log(`Found comments: ${JSON.stringify(comments, null, 2)}`)
147
- const releaseComments = comments.filter(c => c.login === 'github-actions[bot]' && c.body.includes('Release is at'))
148
-
149
- for (const comment of releaseComments) {
150
- console.log(`Release comment: ${JSON.stringify(comment, null, 2)}`)
151
- await github.rest.issues.deleteComment({ owner, repo, comment_id: comment.id })
152
- }
153
-
154
168
  const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
155
- await github.rest.issues.createComment({
156
- owner,
157
- repo,
158
- issue_number,
159
- body: `${body}- Workflow run: :arrows_counterclockwise: ${runUrl}`,
160
- })
169
+
170
+ return [
171
+ '## Release Workflow\n',
172
+ ...releases.map(r => `- \`${r.pkgName}@${r.version}\` ${r.url}`),
173
+ `- Workflow run: :arrows_counterclockwise: ${runUrl}`,
174
+ ].join('\n')
175
+ - name: Create Release PR Comment
176
+ id: create-comment
177
+ uses: peter-evans/create-or-update-comment@v3
178
+ with:
179
+ issue-number: $\{{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
180
+ body: $\{{ steps.comment-text.outputs.result }}
161
181
 
162
182
  release-integration:
163
183
  needs: release
164
184
  name: Release Integration
165
- if: needs.release.outputs.release
166
- {{> jobReleaseIntegrationYml }}
185
+ if: needs.release.outputs.releases
186
+ uses: ./.github/workflows/release-integration.yml
187
+ {{#if publish}}
188
+ permissions:
189
+ id-token: write
190
+ secrets:
191
+ PUBLISH_TOKEN: $\{{ secrets.PUBLISH_TOKEN }}
192
+ {{/if}}
193
+ with:
194
+ releases: $\{{ needs.release.outputs.releases }}
167
195
 
168
196
  post-release-integration:
169
- needs: [release, release-integration]
170
- {{> jobYml jobName="Post Release Integration - Release" jobIf="needs.release.outputs.release && always()" jobSkipSetup=true }}
171
- - name: Get Needs Result
172
- id: needs-result
197
+ needs: [release, release-integration, post-release]
198
+ {{> jobYml jobName="Post Release Integration - Release" jobIf="needs.release.outputs.releases && always()" jobSkipSetup=true }}
199
+ - name: Get Post Release Conclusion
200
+ id: conclusion
173
201
  run: |
174
202
  if [[ "$\{{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
175
203
  result="x"
@@ -179,39 +207,39 @@ jobs:
179
207
  result="white_check_mark"
180
208
  fi
181
209
  echo "result=$result" >> $GITHUB_OUTPUT
182
- - name: Update Release PR Comment
210
+ - name: Find Release PR Comment
211
+ uses: peter-evans/find-comment@v2
212
+ id: found-comment
213
+ with:
214
+ issue-number: $\{{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
215
+ comment-author: 'github-actions[bot]'
216
+ body-includes: '## Release Workflow'
217
+ - name: Create Release PR Comment Text
218
+ id: comment-text
219
+ if: steps.found-comment.outputs.comment-id
183
220
  uses: actions/github-script@v6
184
221
  env:
185
- PR_NUMBER: $\{{ fromJSON(needs.release.outputs.release).prNumber }}
186
- RESULT: $\{{ steps.needs-result.outputs.result }}
222
+ RESULT: $\{{ steps.conclusion.outputs.result }}
223
+ BODY: $\{{ steps.found-comment.outputs.comment-body }}
187
224
  with:
225
+ result-encoding: string
188
226
  script: |
189
- const { PR_NUMBER: issue_number, RESULT } = process.env
190
- const { runId, repo: { owner, repo } } = context
191
-
192
- const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
193
- const updateComment = comments.find(c =>
194
- c.user.login === 'github-actions[bot]' &&
195
- c.body.startsWith('## Release Workflow\n\n') &&
196
- c.body.includes(runId)
197
- )
198
-
199
- if (updateComment) {
200
- console.log('Found comment to update:', JSON.stringify(updateComment, null, 2))
201
- let body = updateComment.body.replace(/Workflow run: :[a-z_]+:/, `Workflow run: :${RESULT}:`)
202
- const tagCodeowner = RESULT !== 'white_check_mark'
203
- if (tagCodeowner) {
204
- body += `\n\n:rotating_light:`
205
- body += ` {{ codeowner }}: The post-release workflow failed for this release.`
206
- body += ` Manual steps may need to be taken after examining the workflow output`
207
- body += ` from the above workflow run. :rotating_light:`
208
- }
209
- await github.rest.issues.updateComment({
210
- owner,
211
- repo,
212
- body,
213
- comment_id: updateComment.id,
214
- })
215
- } else {
216
- console.log('No matching comments found:', JSON.stringify(comments, null, 2))
227
+ const { RESULT, BODY } = process.env
228
+ const body = [BODY.replace(/(Workflow run: :)[a-z_]+(:)/, `$1${RESULT}$2`)]
229
+ if (RESULT !== 'white_check_mark') {
230
+ body.push(':rotating_light::rotating_light::rotating_light:')
231
+ body.push([
232
+ '{{ codeowner }}: The post-release workflow failed for this release.',
233
+ 'Manual steps may need to be taken after examining the workflow output.'
234
+ ].join(' '))
235
+ body.push(':rotating_light::rotating_light::rotating_light:')
217
236
  }
237
+ return body.join('\n\n').trim()
238
+ - name: Update Release PR Comment
239
+ if: steps.comment-text.outputs.result
240
+ uses: peter-evans/create-or-update-comment@v3
241
+ with:
242
+ comment-id: $\{{ steps.found-comment.outputs.comment-id }}
243
+ body: $\{{ steps.comment-text.outputs.result }}
244
+ edit-mode: 'replace'
245
+