Skip to content

Commit c293053

Browse files
committedSep 21, 2022
feat!: postinstall for dependabot template-oss PR
BREAKING CHANGE: `make-fetch-happen` is now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0`
1 parent 729bc74 commit c293053

14 files changed

+617
-132
lines changed
 

‎.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 2
44

55
updates:
66
- package-ecosystem: npm
7-
directory: "/"
7+
directory: /
88
schedule:
99
interval: daily
1010
allow:

‎.github/matchers/tap.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
]
3030
}
3131
]
32-
}
32+
}

‎.github/workflows/audit.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@ on:
1010

1111
jobs:
1212
audit:
13+
name: Audit Dependencies
14+
if: github.repository_owner == 'npm'
1315
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash
1419
steps:
15-
- uses: actions/checkout@v3
16-
- name: Setup git user
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- name: Setup Git User
1723
run: |
1824
git config --global user.email "npm-cli+bot@github.com"
1925
git config --global user.name "npm CLI robot"
20-
- uses: actions/setup-node@v3
26+
- name: Setup Node
27+
uses: actions/setup-node@v3
2128
with:
22-
node-version: 16.x
23-
- name: Update npm to latest
29+
node-version: 18.x
30+
- name: Install npm@latest
2431
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
25-
- run: npm -v
26-
- run: npm i --ignore-scripts --no-audit --no-fund --package-lock
27-
- run: npm audit
32+
- name: npm Version
33+
run: npm -v
34+
- name: Install Dependencies
35+
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
36+
- name: Run Audit
37+
run: npm audit

‎.github/workflows/ci-release.yml

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: CI - Release
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
ref:
9+
required: true
10+
type: string
11+
check-sha:
12+
required: true
13+
type: string
14+
15+
jobs:
16+
lint-all:
17+
name: Lint All
18+
if: github.repository_owner == 'npm'
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
shell: bash
23+
steps:
24+
- name: Create Check
25+
uses: LouisBrunner/checks-action@v1.3.1
26+
id: check
27+
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
status: in_progress
31+
name: Lint All
32+
sha: ${{ inputs.check-sha }}
33+
# XXX: this does not work when using the default GITHUB_TOKEN.
34+
# Instead we post the main job url to the PR as a comment which
35+
# will link to all the other checks. To work around this we would
36+
# need to create a GitHub that would create on-demand tokens.
37+
# https://github.com/LouisBrunner/checks-action/issues/18
38+
# details_url:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
with:
42+
ref: ${{ inputs.ref }}
43+
- name: Setup Git User
44+
run: |
45+
git config --global user.email "npm-cli+bot@github.com"
46+
git config --global user.name "npm CLI robot"
47+
- name: Setup Node
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: 18.x
51+
- name: Install npm@latest
52+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
53+
- name: npm Version
54+
run: npm -v
55+
- name: Install Dependencies
56+
run: npm i --ignore-scripts --no-audit --no-fund
57+
- name: Lint
58+
run: npm run lint --ignore-scripts
59+
- name: Post Lint
60+
run: npm run postlint --ignore-scripts
61+
- name: Conclude Check
62+
uses: LouisBrunner/checks-action@v1.3.1
63+
if: always()
64+
with:
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
conclusion: ${{ job.status }}
67+
check_id: ${{ steps.check.outputs.check_id }}
68+
69+
test-all:
70+
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
71+
if: github.repository_owner == 'npm'
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
platform:
76+
- name: Linux
77+
os: ubuntu-latest
78+
shell: bash
79+
- name: macOS
80+
os: macos-latest
81+
shell: bash
82+
- name: Windows
83+
os: windows-latest
84+
shell: cmd
85+
node-version:
86+
- 14.17.0
87+
- 14.x
88+
- 16.13.0
89+
- 16.x
90+
- 18.0.0
91+
- 18.x
92+
runs-on: ${{ matrix.platform.os }}
93+
defaults:
94+
run:
95+
shell: ${{ matrix.platform.shell }}
96+
steps:
97+
- name: Create Check
98+
uses: LouisBrunner/checks-action@v1.3.1
99+
id: check
100+
101+
with:
102+
token: ${{ secrets.GITHUB_TOKEN }}
103+
status: in_progress
104+
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
105+
sha: ${{ inputs.check-sha }}
106+
# XXX: this does not work when using the default GITHUB_TOKEN.
107+
# Instead we post the main job url to the PR as a comment which
108+
# will link to all the other checks. To work around this we would
109+
# need to create a GitHub that would create on-demand tokens.
110+
# https://github.com/LouisBrunner/checks-action/issues/18
111+
# details_url:
112+
- name: Checkout
113+
uses: actions/checkout@v3
114+
with:
115+
ref: ${{ inputs.ref }}
116+
- name: Setup Git User
117+
run: |
118+
git config --global user.email "npm-cli+bot@github.com"
119+
git config --global user.name "npm CLI robot"
120+
- name: Setup Node
121+
uses: actions/setup-node@v3
122+
with:
123+
node-version: ${{ matrix.node-version }}
124+
- name: Update Windows npm
125+
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
126+
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
127+
run: |
128+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
129+
tar xf npm-7.5.4.tgz
130+
cd package
131+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
132+
cd ..
133+
rmdir /s /q package
134+
- name: Install npm@7
135+
if: startsWith(matrix.node-version, '10.')
136+
run: npm i --prefer-online --no-fund --no-audit -g npm@7
137+
- name: Install npm@latest
138+
if: ${{ !startsWith(matrix.node-version, '10.') }}
139+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
140+
- name: npm Version
141+
run: npm -v
142+
- name: Install Dependencies
143+
run: npm i --ignore-scripts --no-audit --no-fund
144+
- name: Add Problem Matcher
145+
run: echo "::add-matcher::.github/matchers/tap.json"
146+
- name: Test
147+
run: npm test --ignore-scripts -ws -iwr --if-present
148+
- name: Conclude Check
149+
uses: LouisBrunner/checks-action@v1.3.1
150+
if: always()
151+
with:
152+
token: ${{ secrets.GITHUB_TOKEN }}
153+
conclusion: ${{ job.status }}
154+
check_id: ${{ steps.check.outputs.check_id }}

‎.github/workflows/ci.yml

+50-31
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ name: CI
55
on:
66
workflow_dispatch:
77
pull_request:
8-
branches:
9-
- '*'
108
push:
119
branches:
1210
- main
@@ -17,54 +15,73 @@ on:
1715

1816
jobs:
1917
lint:
18+
name: Lint
19+
if: github.repository_owner == 'npm'
2020
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
shell: bash
2124
steps:
22-
- uses: actions/checkout@v3
23-
- name: Setup git user
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Setup Git User
2428
run: |
2529
git config --global user.email "npm-cli+bot@github.com"
2630
git config --global user.name "npm CLI robot"
27-
- uses: actions/setup-node@v3
31+
- name: Setup Node
32+
uses: actions/setup-node@v3
2833
with:
29-
node-version: 16.x
30-
- name: Update npm to latest
34+
node-version: 18.x
35+
- name: Install npm@latest
3136
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
32-
- run: npm -v
33-
- run: npm i --ignore-scripts --no-audit --no-fund
34-
- run: npm run lint
37+
- name: npm Version
38+
run: npm -v
39+
- name: Install Dependencies
40+
run: npm i --ignore-scripts --no-audit --no-fund
41+
- name: Lint
42+
run: npm run lint --ignore-scripts
43+
- name: Post Lint
44+
run: npm run postlint --ignore-scripts
3545

3646
test:
47+
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
48+
if: github.repository_owner == 'npm'
3749
strategy:
3850
fail-fast: false
3951
matrix:
40-
node-version:
41-
- 12.13.0
42-
- 12.x
43-
- 14.15.0
44-
- 14.x
45-
- 16.0.0
46-
- 16.x
4752
platform:
48-
- os: ubuntu-latest
53+
- name: Linux
54+
os: ubuntu-latest
4955
shell: bash
50-
- os: macos-latest
56+
- name: macOS
57+
os: macos-latest
5158
shell: bash
52-
- os: windows-latest
59+
- name: Windows
60+
os: windows-latest
5361
shell: cmd
62+
node-version:
63+
- 14.17.0
64+
- 14.x
65+
- 16.13.0
66+
- 16.x
67+
- 18.0.0
68+
- 18.x
5469
runs-on: ${{ matrix.platform.os }}
5570
defaults:
5671
run:
5772
shell: ${{ matrix.platform.shell }}
5873
steps:
59-
- uses: actions/checkout@v3
60-
- name: Setup git user
74+
- name: Checkout
75+
uses: actions/checkout@v3
76+
- name: Setup Git User
6177
run: |
6278
git config --global user.email "npm-cli+bot@github.com"
6379
git config --global user.name "npm CLI robot"
64-
- uses: actions/setup-node@v3
80+
- name: Setup Node
81+
uses: actions/setup-node@v3
6582
with:
6683
node-version: ${{ matrix.node-version }}
67-
- name: Update to workable npm (windows)
84+
- name: Update Windows npm
6885
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
6986
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
7087
run: |
@@ -74,15 +91,17 @@ jobs:
7491
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
7592
cd ..
7693
rmdir /s /q package
77-
- name: Update npm to 7
78-
# If we do test on npm 10 it needs npm7
94+
- name: Install npm@7
7995
if: startsWith(matrix.node-version, '10.')
8096
run: npm i --prefer-online --no-fund --no-audit -g npm@7
81-
- name: Update npm to latest
97+
- name: Install npm@latest
8298
if: ${{ !startsWith(matrix.node-version, '10.') }}
8399
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
84-
- run: npm -v
85-
- name: add tap problem matcher
100+
- name: npm Version
101+
run: npm -v
102+
- name: Install Dependencies
103+
run: npm i --ignore-scripts --no-audit --no-fund
104+
- name: Add Problem Matcher
86105
run: echo "::add-matcher::.github/matchers/tap.json"
87-
- run: npm i --ignore-scripts --no-audit --no-fund
88-
- run: npm test --ignore-scripts
106+
- name: Test
107+
run: npm test --ignore-scripts -iwr

‎.github/workflows/codeql-analysis.yml

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# This file is automatically added by @npmcli/template-oss. Do not edit.
22

3-
name: "CodeQL"
3+
name: CodeQL
44

55
on:
66
push:
77
branches:
88
- main
99
- latest
1010
pull_request:
11-
# The branches below must be a subset of the branches above
1211
branches:
1312
- main
1413
- latest
@@ -24,21 +23,16 @@ jobs:
2423
actions: read
2524
contents: read
2625
security-events: write
27-
28-
strategy:
29-
fail-fast: false
30-
matrix:
31-
language: [ javascript ]
32-
3326
steps:
34-
- uses: actions/checkout@v3
35-
- name: Setup git user
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
- name: Setup Git User
3630
run: |
3731
git config --global user.email "npm-cli+bot@github.com"
3832
git config --global user.name "npm CLI robot"
3933
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v1
34+
uses: github/codeql-action/init@v2
4135
with:
42-
languages: ${{ matrix.language }}
36+
languages: javascript
4337
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@v1
38+
uses: github/codeql-action/analyze@v2

‎.github/workflows/post-dependabot.yml

+67-19
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,91 @@
11
# This file is automatically added by @npmcli/template-oss. Do not edit.
22

3-
name: Post Dependabot Actions
3+
name: Post Dependabot
44

55
on: pull_request
66

7-
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
87
permissions:
98
contents: write
109

1110
jobs:
12-
template-oss-apply:
11+
template-oss:
12+
name: template-oss
13+
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
1314
runs-on: ubuntu-latest
14-
if: github.actor == 'dependabot[bot]'
15+
defaults:
16+
run:
17+
shell: bash
1518
steps:
16-
- uses: actions/checkout@v3
17-
- name: Setup git user
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
ref: ${{ github.event.pull_request.head_ref }}
23+
- name: Setup Git User
1824
run: |
1925
git config --global user.email "npm-cli+bot@github.com"
2026
git config --global user.name "npm CLI robot"
21-
- uses: actions/setup-node@v3
27+
- name: Setup Node
28+
uses: actions/setup-node@v3
2229
with:
23-
node-version: 16.x
24-
- name: Update npm to latest
30+
node-version: 18.x
31+
- name: Install npm@latest
2532
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
26-
- run: npm -v
27-
- name: Dependabot metadata
33+
- name: npm Version
34+
run: npm -v
35+
- name: Install Dependencies
36+
run: npm i --ignore-scripts --no-audit --no-fund
37+
- name: Fetch Dependabot Metadata
2838
id: metadata
29-
uses: dependabot/fetch-metadata@v1.1.1
39+
uses: dependabot/fetch-metadata@v1
3040
with:
31-
github-token: "${{ secrets.GITHUB_TOKEN }}"
32-
- name: npm install and commit
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
# Dependabot can update multiple directories so we output which directory
44+
# it is acting on so we can run the command for the correct root or workspace
45+
- name: Get Dependabot Directory
3346
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
47+
id: flags
48+
run: |
49+
if [[ "${{ steps.metadata.outputs.directory }}" == "/" ]]; then
50+
echo "::set-output name=workspace::-iwr"
51+
else
52+
echo "::set-output name=workspace::-w ${{ steps.metadata.outputs.directory }}"
53+
fi
54+
55+
- name: Apply Changes
56+
if: steps.flags.outputs.workspace
57+
id: apply
58+
run: |
59+
npm run template-oss-apply ${{ steps.flags.outputs.workspace }}
60+
if [[ `git status --porcelain` ]]; then
61+
echo "::set-output name=changes::true"
62+
fi
63+
64+
# This step will fail if template-oss has made any workflow updates. It is impossible
65+
# for a workflow to update other workflows. In the case it does fail, we continue
66+
# and then try to apply only a portion of the changes in the next step
67+
- name: Push All Changes
68+
if: steps.apply.outputs.changes
69+
id: push
70+
continue-on-error: true
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
git commit -am "chore: postinstall for dependabot template-oss PR"
75+
git push
76+
77+
- name: Push All Changes Except Workflows
78+
if: steps.push.outcome == 'failure'
3479
env:
3580
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3681
run: |
37-
gh pr checkout ${{ github.event.pull_request.number }}
38-
npm install --ignore-scripts --no-audit --no-fund
39-
npm run template-oss-apply
40-
git add .
82+
git reset HEAD~
83+
git checkout HEAD -- .github/workflows/
84+
git clean -fd .github/workflows/
4185
git commit -am "chore: postinstall for dependabot template-oss PR"
4286
git push
43-
npm run lint
87+
88+
- name: Check Changes
89+
if: steps.apply.outputs.changes
90+
run: |
91+
npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check

‎.github/workflows/pull-request.yml

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically added by @npmcli/template-oss. Do not edit.
22

3-
name: Pull Request Linting
3+
name: Pull Request
44

55
on:
66
pull_request:
@@ -11,28 +11,38 @@ on:
1111
- synchronize
1212

1313
jobs:
14-
check:
15-
name: Check PR Title or Commits
14+
commitlint:
15+
name: Lint Commits
16+
if: github.repository_owner == 'npm'
1617
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
shell: bash
1721
steps:
18-
- uses: actions/checkout@v3
22+
- name: Checkout
23+
uses: actions/checkout@v3
1924
with:
2025
fetch-depth: 0
21-
- name: Setup git user
26+
- name: Setup Git User
2227
run: |
2328
git config --global user.email "npm-cli+bot@github.com"
2429
git config --global user.name "npm CLI robot"
25-
- uses: actions/setup-node@v3
30+
- name: Setup Node
31+
uses: actions/setup-node@v3
2632
with:
27-
node-version: 16.x
28-
- name: Update npm to latest
33+
node-version: 18.x
34+
- name: Install npm@latest
2935
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
30-
- run: npm -v
31-
- name: Install deps
32-
run: npm i -D @commitlint/cli @commitlint/config-conventional
33-
- name: Check commits OR PR title
34-
env:
35-
PR_TITLE: ${{ github.event.pull_request.title }}
36+
- name: npm Version
37+
run: npm -v
38+
- name: Install Dependencies
39+
run: npm i --ignore-scripts --no-audit --no-fund
40+
- name: Run Commitlint on Commits
41+
id: commit
42+
continue-on-error: true
3643
run: |
37-
npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \
38-
|| echo $PR_TITLE | npx --offline commitlint -V
44+
npx --offline commitlint -V --from origin/${{ github.base_ref }} --to ${{ github.event.pull_request.head.sha }}
45+
- name: Run Commitlint on PR Title
46+
if: steps.commit.outcome == 'failure'
47+
run: |
48+
echo ${{ github.event.pull_request.title }} | npx --offline commitlint -V

‎.github/workflows/release-please.yml

-26
This file was deleted.

‎.github/workflows/release.yml

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Release
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- latest
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
checks: write
15+
16+
jobs:
17+
release:
18+
outputs:
19+
pr: ${{ steps.release.outputs.pr }}
20+
releases: ${{ steps.release.outputs.releases }}
21+
release-flags: ${{ steps.release.outputs.release-flags }}
22+
branch: ${{ steps.release.outputs.pr-branch }}
23+
pr-number: ${{ steps.release.outputs.pr-number }}
24+
comment-id: ${{ steps.pr-comment.outputs.result }}
25+
check-id: ${{ steps.check.outputs.check_id }}
26+
name: Release
27+
if: github.repository_owner == 'npm'
28+
runs-on: ubuntu-latest
29+
defaults:
30+
run:
31+
shell: bash
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
- name: Setup Git User
36+
run: |
37+
git config --global user.email "npm-cli+bot@github.com"
38+
git config --global user.name "npm CLI robot"
39+
- name: Setup Node
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: 18.x
43+
- name: Install npm@latest
44+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
45+
- name: npm Version
46+
run: npm -v
47+
- name: Install Dependencies
48+
run: npm i --ignore-scripts --no-audit --no-fund
49+
- name: Release Please
50+
id: release
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
npx --offline template-oss-release-please ${{ github.ref_name }}
55+
- name: Post Pull Request Comment
56+
if: steps.release.outputs.pr-number
57+
uses: actions/github-script@v6
58+
id: pr-comment
59+
env:
60+
PR_NUMBER: ${{ steps.release.outputs.pr-number }}
61+
with:
62+
script: |
63+
const repo = { owner: context.repo.owner, repo: context.repo.repo }
64+
const issue = { ...repo, issue_number: process.env.PR_NUMBER }
65+
66+
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
67+
68+
let body = '## Release Manager\n\n'
69+
70+
const comments = await github.paginate(github.rest.issues.listComments, issue)
71+
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
72+
73+
body += `- Release workflow run: ${workflow.html_url}`
74+
if (commentId) {
75+
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
76+
} else {
77+
const { data: comment } = await github.rest.issues.createComment({ ...issue, body })
78+
commentId = comment?.id
79+
}
80+
81+
return commentId
82+
- name: Create Check
83+
uses: LouisBrunner/checks-action@v1.3.1
84+
id: check
85+
if: steps.release.outputs.pr-number
86+
with:
87+
token: ${{ secrets.GITHUB_TOKEN }}
88+
status: in_progress
89+
name: Release
90+
sha: ${{ steps.release.outputs.pr-sha }}
91+
# XXX: this does not work when using the default GITHUB_TOKEN.
92+
# Instead we post the main job url to the PR as a comment which
93+
# will link to all the other checks. To work around this we would
94+
# need to create a GitHub that would create on-demand tokens.
95+
# https://github.com/LouisBrunner/checks-action/issues/18
96+
# details_url:
97+
98+
update:
99+
needs: release
100+
outputs:
101+
sha: ${{ steps.commit.outputs.sha }}
102+
check-id: ${{ steps.check.outputs.check_id }}
103+
name: Update - Release
104+
if: github.repository_owner == 'npm' && needs.release.outputs.pr
105+
runs-on: ubuntu-latest
106+
defaults:
107+
run:
108+
shell: bash
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v3
112+
with:
113+
fetch-depth: 0
114+
ref: ${{ needs.release.outputs.branch }}
115+
- name: Setup Git User
116+
run: |
117+
git config --global user.email "npm-cli+bot@github.com"
118+
git config --global user.name "npm CLI robot"
119+
- name: Setup Node
120+
uses: actions/setup-node@v3
121+
with:
122+
node-version: 18.x
123+
- name: Install npm@latest
124+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
125+
- name: npm Version
126+
run: npm -v
127+
- name: Install Dependencies
128+
run: npm i --ignore-scripts --no-audit --no-fund
129+
- name: Run Post Pull Request Actions
130+
env:
131+
RELEASE_PR_NUMBER: ${{ needs.release.outputs.pr-number }}
132+
RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }}
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
run: |
135+
npm run rp-pull-request --ignore-scripts -ws -iwr --if-present
136+
- name: Commit
137+
id: commit
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
run: |
141+
git commit --all --amend --no-edit || true
142+
git push --force-with-lease
143+
echo "::set-output name=sha::$(git rev-parse HEAD)"
144+
- name: Create Check
145+
uses: LouisBrunner/checks-action@v1.3.1
146+
id: check
147+
148+
with:
149+
token: ${{ secrets.GITHUB_TOKEN }}
150+
status: in_progress
151+
name: Release
152+
sha: ${{ steps.commit.outputs.sha }}
153+
# XXX: this does not work when using the default GITHUB_TOKEN.
154+
# Instead we post the main job url to the PR as a comment which
155+
# will link to all the other checks. To work around this we would
156+
# need to create a GitHub that would create on-demand tokens.
157+
# https://github.com/LouisBrunner/checks-action/issues/18
158+
# details_url:
159+
- name: Conclude Check
160+
uses: LouisBrunner/checks-action@v1.3.1
161+
if: always()
162+
with:
163+
token: ${{ secrets.GITHUB_TOKEN }}
164+
conclusion: ${{ job.status }}
165+
check_id: ${{ needs.release.outputs.check-id }}
166+
167+
ci:
168+
name: CI - Release
169+
needs: [ release, update ]
170+
if: needs.release.outputs.pr
171+
uses: ./.github/workflows/ci-release.yml
172+
with:
173+
ref: ${{ needs.release.outputs.branch }}
174+
check-sha: ${{ needs.update.outputs.sha }}
175+
176+
post-ci:
177+
needs: [ release, update, ci ]
178+
name: Post CI - Release
179+
if: github.repository_owner == 'npm' && needs.release.outputs.pr && always()
180+
runs-on: ubuntu-latest
181+
defaults:
182+
run:
183+
shell: bash
184+
steps:
185+
- name: Get Needs Result
186+
id: needs-result
187+
run: |
188+
result=""
189+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
190+
result="failure"
191+
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
192+
result="cancelled"
193+
else
194+
result="success"
195+
fi
196+
echo "::set-output name=result::$result"
197+
- name: Conclude Check
198+
uses: LouisBrunner/checks-action@v1.3.1
199+
if: always()
200+
with:
201+
token: ${{ secrets.GITHUB_TOKEN }}
202+
conclusion: ${{ steps.needs-result.outputs.result }}
203+
check_id: ${{ needs.update.outputs.check-id }}
204+
205+
post-release:
206+
needs: release
207+
name: Post Release - Release
208+
if: github.repository_owner == 'npm' && needs.release.outputs.releases
209+
runs-on: ubuntu-latest
210+
defaults:
211+
run:
212+
shell: bash
213+
steps:
214+
- name: Checkout
215+
uses: actions/checkout@v3
216+
- name: Setup Git User
217+
run: |
218+
git config --global user.email "npm-cli+bot@github.com"
219+
git config --global user.name "npm CLI robot"
220+
- name: Setup Node
221+
uses: actions/setup-node@v3
222+
with:
223+
node-version: 18.x
224+
- name: Install npm@latest
225+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
226+
- name: npm Version
227+
run: npm -v
228+
- name: Install Dependencies
229+
run: npm i --ignore-scripts --no-audit --no-fund
230+
- name: Run Post Release Actions
231+
env:
232+
RELEASES: ${{ needs.release.outputs.releases }}
233+
run: |
234+
npm run rp-release --ignore-scripts --if-present ${{ join(fromJSON(needs.release.outputs.release-flags), ' ') }}

‎.gitignore

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@
44
/*
55

66
# keep these
7-
!/.eslintrc.local.*
87
!**/.gitignore
9-
!/docs/
10-
!/tap-snapshots/
11-
!/test/
12-
!/map.js
13-
!/scripts/
14-
!/README*
15-
!/LICENSE*
16-
!/CHANGELOG*
178
!/.commitlintrc.js
189
!/.eslintrc.js
10+
!/.eslintrc.local.*
1911
!/.github/
2012
!/.gitignore
2113
!/.npmrc
22-
!/CODE_OF_CONDUCT.md
23-
!/SECURITY.md
14+
!/.release-please-manifest.json
2415
!/bin/
16+
!/CHANGELOG*
17+
!/CODE_OF_CONDUCT.md
18+
!/docs/
2519
!/lib/
20+
!/LICENSE*
21+
!/map.js
2622
!/package.json
23+
!/README*
24+
!/release-please-config.json
25+
!/scripts/
26+
!/SECURITY.md
27+
!/tap-snapshots/
28+
!/test/

‎.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "10.2.1"
3+
}

‎package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"lib/"
99
],
1010
"scripts": {
11-
"preversion": "npm test",
12-
"postversion": "npm publish",
13-
"prepublishOnly": "git push origin --follow-tags",
1411
"test": "tap",
1512
"posttest": "npm run lint",
1613
"eslint": "eslint",
@@ -64,16 +61,20 @@
6461
"tap": "^16.0.0"
6562
},
6663
"engines": {
67-
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
64+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
6865
},
6966
"tap": {
7067
"color": 1,
7168
"files": "test/*.js",
7269
"check-coverage": true,
73-
"timeout": 60
70+
"timeout": 60,
71+
"nyc-arg": [
72+
"--exclude",
73+
"tap-snapshots/**"
74+
]
7475
},
7576
"templateOSS": {
7677
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
77-
"version": "3.6.0"
78+
"version": "4.3.2"
7879
}
7980
}

‎release-please-config.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"exclude-packages-from-root": true,
3+
"group-pull-request-title-pattern": "chore: release ${version}",
4+
"pull-request-title-pattern": "chore: release${component} ${version}",
5+
"changelog-sections": [
6+
{
7+
"type": "feat",
8+
"section": "Features",
9+
"hidden": false
10+
},
11+
{
12+
"type": "fix",
13+
"section": "Bug Fixes",
14+
"hidden": false
15+
},
16+
{
17+
"type": "docs",
18+
"section": "Documentation",
19+
"hidden": false
20+
},
21+
{
22+
"type": "deps",
23+
"section": "Dependencies",
24+
"hidden": false
25+
},
26+
{
27+
"type": "chore",
28+
"hidden": true
29+
}
30+
],
31+
"packages": {
32+
".": {
33+
"package-name": ""
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)
Please sign in to comment.