-
-
Notifications
You must be signed in to change notification settings - Fork 28
59 lines (53 loc) · 1.57 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
# 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: npm Publish Package
on:
pull_request:
types:
- closed
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run compile
- run: npm test
- run: npm run dist
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Check if tag is a version
id: check_version
run: |
git fetch --tags
VERSION_TAG=$(git tag --list --sort=-version:refname "v*" | head -n 1)
echo "Version: $VERSION_TAG"
LAST_VER=v$(npm view js-big-decimal version)
echo "Published Version: $LAST_VER"
if [[ "$VERSION_TAG" != "$LAST_VER" ]]; then
echo "is_version=true" >> $GITHUB_ENV
else
echo "is_version=false" >> $GITHUB_ENV
fi
- name: Debug env
run: |
echo "is_version: ${{env.is_version}}"
- name: Publish
if: env.is_version == 'true'
run: |
npm ci
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}