-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 1.97 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
on:
push:
branches:
- main
pull_request:
name: Create Release
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Check formatting
run: |
npm run format
if [ ! "$(git status --porcelain=v1)" == "" ];
then exit 1;
fi
- name: Check types
run: npm run typecheck
- name: Run tests
run: npm run coverage
build:
name: Create Release
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Check if package version changed
id: check_version
run: |
version="v$(cat package.json | jq -r '.version')"
echo Version: $version
git tag
if [ $(git tag -l "$version") ]; then
echo "Tag $version already exists."
else
echo "version_tag=$version" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-node@v4
if: steps.check_version.outputs.version_tag
with:
node-version-file: .nvmrc
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Create GitHub release
if: steps.check_version.outputs.version_tag
run: |
gh release create ${{ steps.check_version.outputs.version_tag }} --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
if: steps.check_version.outputs.version_tag
run: |
npm ci
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}