-
Notifications
You must be signed in to change notification settings - Fork 43
68 lines (58 loc) · 2.01 KB
/
publish-a-private-npm-package.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
name: Publish A Private NPM package
on:
push:
tags:
- pv*
jobs:
# only publish private npm package on private repo: perp-lushan
publish-private-npm-package:
if: ${{ github.repository == 'perpetual-protocol/perp-lushan' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Get npm cache directory
id: npm-cache
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
${{ steps.npm-cache.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://npm.pkg.github.com'
scope: '@perpetual-protocol'
- name: Assert git tag and package version
run: |
VERSION_IN_PKG=$(npm pkg get version | sed 's/"//g')
VERSION_IN_GIT_TAG=${GITHUB_REF_NAME:2}
if [ $VERSION_IN_PKG != $VERSION_IN_GIT_TAG ]; then echo "not match" && exit 1; else echo 0; fi
- name: Install contract dependencies
run: npm ci
env:
CI: true
- name: Build contract package
run: npm run build
env:
CI: true
- name: Publish npm package
run: |
npm pkg set name="@perpetual-protocol/lushan"
npm pkg set repository.url="https://github.com/perpetual-protocol/perp-lushan.git"
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "npm package @perpetual-protocol/lushan@${{ github.event.inputs.version }} ${{github.ref}} released on github package"