-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (59 loc) · 1.92 KB
/
ci.yaml
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
72
73
74
75
name: Continuous Integration
on:
push:
pull_request:
release:
types: [published]
workflow_dispatch:
jobs:
build:
name: Build Package
runs-on: ubuntu-latest
strategy:
matrix:
# the Node.js versions to build on
node-version: [ lts/-1, lts/* ]
steps:
- name: Checkout the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up ${{ matrix.node-version }} environment
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Lint the project
run: npm run lint
- name: Build the project
run: npm run build
env:
CI: true
publish:
name: Publish release to NPM
needs: build
runs-on: ubuntu-latest
# Publish only if we've received a release event and the tag starts with "v" (aka v1.2.3)
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
# Ensure we have permissions to provide our provenance attestation.
permissions:
id-token: write
steps:
- name: Checkout the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
# Setup .npmrc file to publish to npm
- name: Setup the node environment
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: lts/-1
registry-url: 'https://registry.npmjs.org'
- name: Install package
run: npm ci
- name: Build package
run: npm run build
- name: Publish to NPM
run: |
TAG=$(echo $GITHUB_REF_NAME | grep -oP 'v\d+\.\d+\.\d+-?\K(\w+)?')
echo $TAG
npm publish --tag ${TAG:-latest} --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}