-
Notifications
You must be signed in to change notification settings - Fork 5
79 lines (66 loc) · 2.29 KB
/
npm-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Instructions:
#
# Setup:
#
# 1. ensure in npm account settings you have 2FA setup for authorization only or disabled
# 2. in npm "Access Tokens" create a new token for read and publish
# 3. in github repository "Settings" -> "Secrets" add that npm token with name "NPM_TOKEN" (as used in the action file)
#
# Create a New Release:
#
# 1. commit (and maybe push) all your changes and ensure action "unit-tests" succeeds
# 2. create a new git version tag: `yarn version --patch` (see yarn help version for more options)
# 3. push new tag to github: `git push --follow-tags`
#
# Re-run the release action (after an error)
#
# Because the action is only triggered when a new tag is pushed, you'll need to:
#
# 1. delete the failed version on the remote and locally:
# `git push --delete origin v1.2.3`
# `git tag --delete v1.2.3`
# 2. recreate the annotated tag:
# `git tag -a v1.2.3 -m v1.2.3
# 3. push
# `git push --follow-tags`
name: npm-publish
on:
push:
# PRs do not contain tags, so we do not need any other filter here
tags:
- 'v*'
jobs:
publish:
runs-on: ${{ matrix.os }}
strategy:
# using matrix with just one OS and node version does not make much sense
# but that way we can copy and paste the cache steps from other actions
# using more oses and/or node version in their matrix
matrix:
os: [ubuntu-latest]
node: [14]
name: ${{ matrix.os }} Node ${{ matrix.node }} cache
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
registry-url: https://registry.npmjs.org/
- name: Get yarn cache directory
id: yarn-cache
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/[email protected]
id: cache
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-
${{ runner.os }}-node-
- run: yarn install --frozen-lockfile
- run: yarn run lint
- run: yarn run test
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}