-
Notifications
You must be signed in to change notification settings - Fork 22
53 lines (50 loc) · 1.33 KB
/
node.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
name: Node
on:
push:
branches: [ main ]
tags:
- "nodejs/v**"
paths:
- '.github/workflows/node.yml'
- 'nodejs/**'
- 'test-resources/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/node.yml'
- 'nodejs/**'
- 'test-resources/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: cd nodejs && yarn --frozen-lockfile && yarn test
publish:
runs-on: ubuntu-latest
# Runs only on tags push
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Get version from tag
uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.ref_name }}
# matches tags starting with "nodejs/v" and uses the rest of the string as the version
regex: 'nodejs\/v(.*)'
- name: Publish to npm
run: |
cd nodejs
yarn --frozen-lockfile
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
VERSION=${{ steps.regex-match.outputs.group1 }}
npm version $VERSION
npm publish