-
Notifications
You must be signed in to change notification settings - Fork 9
71 lines (61 loc) · 1.79 KB
/
build.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
name: Build
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [18.x]
os: [ubuntu-latest]
steps:
- id: setup-node
name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Check out code repository source code
uses: actions/checkout@v2
- name: Install dependencies
run: yarn
- name: Run build
run: yarn build
# Publishing is done in a separate job to allow
# for all matrix builds to complete.
release:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
node: [18]
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Check out repo
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Check if publish needed
run: |
name="$(jq -r .name package.json)"
npmver="$(npm show $name version || echo v0.0.0)"
pkgver="$(jq -r .version package.json)"
if [ "$npmver" = "$pkgver" ]
then
echo "Package version ($pkgver) is the same as last published NPM version ($npmver), skipping publish."
else
echo "Package version ($pkgver) is different from latest NPM version ($npmver), publishing!"
echo "publish=true" >> $GITHUB_ENV
fi
- name: Publish
if: env.publish == 'true'
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
yarn
npm publish