-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (68 loc) · 2.2 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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: publish
on:
pull_request:
types: [closed]
branches:
- develop
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Restore node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
modules-${{ hashFiles('**/yarn.lock') }}
modules-
- run: yarn
- run: yarn test
publish-npm:
needs: build
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: |
git config --local user.email "[email protected]"
git config --local user.name "fupengl"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
- name: Restore node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
modules-${{ hashFiles('**/yarn.lock') }}
modules-
- run: yarn
- name: Authenticate with Registry
run: |
yarn logout
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
- run: |
if [ ${{ github.base_ref }} = develop ]; then
yarn version:beta
else
yarn version:release
fi
yarn release:pkg --create-release github