Skip to content

Commit 7979444

Browse files
committed
feat: call release-test workflow after updating release PR
1 parent 7db454c commit 7979444

File tree

9 files changed

+395
-4
lines changed

9 files changed

+395
-4
lines changed

.github/workflows/release-please.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ jobs:
4141
needs: release-please
4242
if: needs.release-please.outputs.pr
4343
runs-on: ubuntu-latest
44+
outputs:
45+
ref: ${{ steps.ref.outputs.branch }}
4446
steps:
47+
- name: Output ref
48+
id: ref
49+
run: echo "::set-output name=branch::${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}"
4550
- uses: actions/checkout@v3
4651
with:
47-
ref: ${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}
52+
ref: ${{ steps.ref.outputs.branch }}
4853
- name: Setup git user
4954
run: |
5055
git config --global user.email "[email protected]"
@@ -64,6 +69,13 @@ jobs:
6469
git commit -am "chore: post pull request" || true
6570
git push
6671
72+
release-test:
73+
needs: post-pr
74+
if: needs.post-pr.outputs.ref
75+
uses: ./.github/workflows/release-test.yml
76+
with:
77+
ref: ${{ needs.post-pr.outputs.ref }}
78+
6779
post-release:
6880
needs: release-please
6981
if: needs.release-please.outputs.release

.github/workflows/release-test.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Release
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
ref:
9+
required: true
10+
type: string
11+
12+
jobs:
13+
lint-all:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: ${{ inputs.ref }}
19+
- name: Setup git user
20+
run: |
21+
git config --global user.email "[email protected]"
22+
git config --global user.name "npm CLI robot"
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: 16.x
26+
- name: Update npm to latest
27+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
28+
- run: npm -v
29+
- run: npm i --ignore-scripts --no-audit --no-fund
30+
- run: npm run lint --if-present --workspaces --include-workspace-root
31+
32+
test-all:
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
node-version:
37+
- 12.13.0
38+
- 12.x
39+
- 14.15.0
40+
- 14.x
41+
- 16.0.0
42+
- 16.x
43+
platform:
44+
- os: ubuntu-latest
45+
shell: bash
46+
- os: macos-latest
47+
shell: bash
48+
- os: windows-latest
49+
shell: cmd
50+
runs-on: ${{ matrix.platform.os }}
51+
defaults:
52+
run:
53+
shell: ${{ matrix.platform.shell }}
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
ref: ${{ inputs.ref }}
58+
- name: Setup git user
59+
run: |
60+
git config --global user.email "[email protected]"
61+
git config --global user.name "npm CLI robot"
62+
- uses: actions/setup-node@v3
63+
with:
64+
node-version: ${{ matrix.node-version }}
65+
- name: Update to workable npm (windows)
66+
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
67+
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
68+
run: |
69+
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
70+
tar xf npm-7.5.4.tgz
71+
cd package
72+
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
73+
cd ..
74+
rmdir /s /q package
75+
- name: Update npm to 7
76+
# If we do test on npm 10 it needs npm7
77+
if: startsWith(matrix.node-version, '10.')
78+
run: npm i --prefer-online --no-fund --no-audit -g npm@7
79+
- name: Update npm to latest
80+
if: ${{ !startsWith(matrix.node-version, '10.') }}
81+
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
82+
- run: npm -v
83+
- run: npm i --ignore-scripts --no-audit --no-fund
84+
- name: add tap problem matcher
85+
run: echo "::add-matcher::.github/matchers/tap.json"
86+
- run: npm run test --if-present --workspaces --include-workspace-root

lib/content/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const releasePlease = () => ({
55
file: 'release-please.yml',
66
filter: (o) => !o.pkg.private,
77
},
8+
'.github/workflows/release-test.yml': {
9+
file: 'release-test.yml',
10+
filter: (o) => !o.pkg.private,
11+
},
812
'.release-please-manifest.json': {
913
file: 'release-please-manifest.json',
1014
filter: (o) => !o.pkg.private,
@@ -93,6 +97,10 @@ module.exports = {
9397
windowsCI: true,
9498
branches: ['main', 'latest'],
9599
defaultBranch: 'main',
100+
// Escape hatch since we write a release test file but the
101+
// CLI has a very custom one we dont want to overwrite. This
102+
// setting allows us to call a workflow by any name during release
103+
releaseTest: 'release-test.yml',
96104
distPaths: ['bin/', 'lib/'],
97105
ciVersions: ['12.13.0', '12.x', '14.15.0', '14.x', '16.0.0', '16.x'],
98106
lockfile: false,

lib/content/release-please.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ jobs:
3131
needs: release-please
3232
if: needs.release-please.outputs.pr
3333
runs-on: ubuntu-latest
34+
outputs:
35+
ref: $\{{ steps.ref.outputs.branch }}
3436
steps:
35-
{{> setupGit with=(obj ref="${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}")}}
37+
- name: Output ref
38+
id: ref
39+
run: echo "::set-output name=branch::$\{{ fromJSON(needs.release-please.outputs.pr).headBranchName }}"
40+
{{> setupGit with=(obj ref="${{ steps.ref.outputs.branch }}")}}
3641
{{> setupNode}}
3742
{{> setupDeps}}
3843
- name: Post pull request actions
@@ -42,6 +47,13 @@ jobs:
4247
npm run rp-pull-request --ignore-scripts --if-present -ws -iwr
4348
git commit -am "chore: post pull request" || true
4449
git push
50+
51+
release-test:
52+
needs: post-pr
53+
if: needs.post-pr.outputs.ref
54+
uses: ./.github/workflows/{{releaseTest}}
55+
with:
56+
ref: $\{{ needs.post-pr.outputs.ref }}
4557

4658
post-release:
4759
needs: release-please

lib/content/release-test.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
lint-all:
12+
runs-on: ubuntu-latest
13+
steps:
14+
{{> setupGit with=(obj ref="${{ inputs.ref }}")}}
15+
{{> setupNode}}
16+
{{> setupDeps}}
17+
- run: npm run lint --if-present --workspaces --include-workspace-root
18+
19+
test-all:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
node-version:
24+
{{#each ciVersions}}
25+
- {{.}}
26+
{{/each}}
27+
platform:
28+
- os: ubuntu-latest
29+
shell: bash
30+
- os: macos-latest
31+
shell: bash
32+
{{#if windowsCI}}
33+
- os: windows-latest
34+
shell: cmd
35+
{{/if}}
36+
runs-on: $\{{ matrix.platform.os }}
37+
defaults:
38+
run:
39+
shell: $\{{ matrix.platform.shell }}
40+
steps:
41+
{{> setupGit with=(obj ref="${{ inputs.ref }}")}}
42+
{{> setupNode useMatrix=true}}
43+
{{> setupDeps}}
44+
- name: add tap problem matcher
45+
run: echo "::add-matcher::.github/matchers/tap.json"
46+
- run: npm run test --if-present --workspaces --include-workspace-root

0 commit comments

Comments
 (0)