-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (62 loc) · 1.98 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
name: CI
on:
push:
paths-ignore:
- "*.md"
branches: [main]
tags:
- "*"
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Cache node_modules
uses: actions/cache@v4
with:
path: |
~/.npm
~/.nvm
~/work/better-sqlite3-migrate/better-sqlite3-migrate/node_modules
~/work/better-sqlite3-migrate/better-sqlite3-migrate/package-lock.json
key: ${{ runner.os }}-node_modules-cache-v3-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-node_modules-cache-v3-
- name: Extract Tag Name
run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: ${{ startsWith(github.ref, 'refs/tags') }}
- name: Run tests
run: |
npm i
npx tsc
npx quick-lint-js ./*.mjs
npm run formatCheck
npx sql-bundle ./test/migrations
NODE_V8_COVERAGE=coverage0 npx c8 -r lcovonly --all --src ./src node --experimental-test-coverage ./test/all.mjs
if: ${{ env.TAG_NAME == '' }}
- name: Report coverage to Coveralls
uses: coverallsapp/github-action@v2
if: ${{ env.TAG_NAME == '' }}
- name: Build SNAPSHOT
run: |
npm pack
if: ${{ env.TAG_NAME == '' }}
- name: Publish RELEASE
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
VERSION="$(echo "$TAG_NAME" | cut -d'v' -f 2)"
echo "Publish a release version=$VERSION for tag $TAG_NAME"
npm --no-git-tag-version --allow-same-version version $VERSION
npm publish
if: ${{ env.TAG_NAME != '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}