-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (42 loc) · 1.26 KB
/
main.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
name: "Test and publish"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: "Test and publish"
runs-on: ubuntu-latest
steps:
#Prepare node environment
- name: "Checkout source code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.ref }}
- name: Read Node.js version from .nvmrc
id: read_nvmrc
run: |
echo "::set-output name=node_version::$(cat .nvmrc)"
- name: "Setup Node.js"
uses: actions/setup-node@v4
with:
node-version: ${{ steps.read_nvmrc.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'
#Run tests
- run: npm ci
- run: npm test
#Increase version in main branch
- name: "Automated Version Bump"
if: github.ref == 'refs/heads/master'
id: version-bump
uses: "phips28/gh-action-bump-version@master"
with:
tag-prefix: ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#Publish to npm in main branch
- run: npm publish
if: github.ref == 'refs/heads/master'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}