Skip to content

Commit 98e3ba4

Browse files
committed
chore(workflows): run tests before publishing a new version to npm
1 parent 96515d7 commit 98e3ba4

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

.github/workflows/publish.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Publish package
2+
23
on:
34
push:
45
tags:
56
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
7+
68
jobs:
79
create-release:
810
name: Create Release
911
runs-on: ubuntu-latest
1012
outputs:
1113
upload_url: ${{ steps.create_release.outputs.upload_url }}
12-
1314
steps:
1415
- name: Create Release
1516
id: create_release
@@ -26,12 +27,27 @@ jobs:
2627
name: Publish to NPM
2728
runs-on: ubuntu-latest
2829
steps:
29-
- uses: actions/checkout@v2
30-
- uses: actions/setup-node@v2
30+
- name: Checkout repository from GitHub
31+
uses: actions/checkout@v2.3.1
32+
- name: Setup npm
33+
uses: actions/setup-node@v2
3134
with:
32-
node-version: "12.x"
35+
node-version: "15"
3336
registry-url: "https://registry.npmjs.org"
34-
- run: npm install
35-
- run: npm publish --access public
37+
# npm cache folder is in ~/, not within the working directory
38+
- name: Cache npm directory
39+
uses: actions/cache@v2
40+
with:
41+
path: ~/.npm
42+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
43+
restore-keys: |
44+
${{ runner.os }}-node-
45+
# Node auth token is needed for private GitHub registry
46+
- name: Install dependencies
47+
run: npm install
48+
- name: Run tests
49+
run: npm run test
50+
- name: Publish
51+
run: npm publish --access public
3652
env:
3753
NODE_AUTH_TOKEN: ${{ secrets.NPM_BOT_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)