-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (97 loc) · 2.5 KB
/
ci.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use NodeJS v${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm ci
- name: Test
run: npm test
- name: Coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./tests/coverage/lcov.info
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use NodeJS v20
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install
run: npm ci
- name: Lint
run: npm run lint
npm:
if: startsWith(github.ref, 'refs/tags/')
needs:
- test
- lint
name: NPM Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use NodeJS v16
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- name: Sanity check
run: |
npm run lint
npm test
- name: Deploy to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
release:
name: Release
needs: npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get tag metadata
id: tag
run: |
TAG_TITLE=${GITHUB_REF#refs/*/}
echo ::set-output name=title::$TAG_TITLE
git -c protocol.version=2 fetch --prune --progress \
--no-recurse-submodules origin \
+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
TAG_BODY="$(git tag -l --format='%(contents)' $TAG_TITLE)"
TAG_BODY="${TAG_BODY//'%'/'%25'}"
TAG_BODY="${TAG_BODY//$'\n'/'%0A'}"
TAG_BODY="${TAG_BODY//$'\r'/'%0D'}"
echo ::set-output name=body::$TAG_BODY
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.title }}
name: ${{ steps.tag.outputs.title }}
body: ${{ steps.tag.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}