Skip to content

Commit 3a14878

Browse files
committed
Update GitHub workflows to use latest Node LTS and modern practices
1 parent b2f965f commit 3a14878

File tree

7 files changed

+95
-55
lines changed

7 files changed

+95
-55
lines changed

.github/workflows/bump.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,38 @@ on:
66
version:
77
description: 'Semver type of new version (major / minor / patch)'
88
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
914

1015
jobs:
1116
bump-version:
1217
name: Bump version
1318
runs-on: ubuntu-latest
1419
steps:
15-
- name: Check out source
16-
uses: actions/checkout@v2
20+
- name: Checkout repo
21+
uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
1724

18-
- name: Setup Node.js
19-
uses: actions/setup-node@v2
25+
- name: Setup Node.js LTS
26+
uses: actions/setup-node@v4
2027
with:
21-
node-version: '16'
28+
node-version: 'lts/*'
2229
cache: 'npm'
2330

2431
- name: Install dependencies
25-
uses: bahmutov/npm-install@v1
32+
run: npm ci
2633

2734
- name: Setup Git
2835
run: |
29-
git config user.name 'Ivan Galiatin'
30-
git config user.email 'arxcaeli@gmail.com'
36+
git config user.name 'github-actions[bot]'
37+
git config user.email 'github-actions[bot]@users.noreply.github.com'
3138
32-
- name: bump version
39+
- name: Bump version
3340
run: npm version ${{ github.event.inputs.version }}
3441

35-
- name: Push latest version
42+
- name: Push changes
3643
run: git push origin master --follow-tags

.github/workflows/main.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,58 @@
11
name: Validate
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
7-
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
8-
9-
runs-on: ${{ matrix.os }}
10-
strategy:
11-
matrix:
12-
node: ['16.x', '18.x', '20.x']
13-
os: [ubuntu-latest, windows-latest, macOS-latest]
7+
name: Build, lint, and test on Node LTS
8+
runs-on: ubuntu-latest
149

1510
steps:
1611
- name: Checkout repo
17-
uses: actions/checkout@v2
12+
uses: actions/checkout@v4
1813

19-
- name: Use Node ${{ matrix.node }}
20-
uses: actions/setup-node@v1
14+
- name: Setup Node.js LTS
15+
uses: actions/setup-node@v4
2116
with:
22-
node-version: ${{ matrix.node }}
17+
node-version: 'lts/*'
18+
cache: 'npm'
2319

24-
- name: Install deps and build (with cache)
25-
uses: bahmutov/npm-install@v1
20+
- name: Cache build outputs
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
dist
25+
.eslintcache
26+
**/.tsbuildinfo
27+
key: ${{ runner.os }}-build-${{ hashFiles('src/**/*', 'tsconfig.json', 'eslint.config.js') }}
28+
restore-keys: |
29+
${{ runner.os }}-build-
30+
31+
- name: Cache test results
32+
uses: actions/cache@v4
2633
with:
27-
working-directory: |
28-
.
29-
examples
34+
path: |
35+
.jest
36+
node_modules/.cache
37+
key: ${{ runner.os }}-tests-${{ hashFiles('src/**/*.test.*', 'src/**/*.spec.*', 'jest.config.ts', 'vitest.config.ts') }}
38+
restore-keys: |
39+
${{ runner.os }}-tests-
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Install example dependencies
45+
run: npm ci
46+
working-directory: ./examples
3047

3148
- name: Lint
32-
run: npm run lint
49+
run: npm run lint -- --cache
50+
51+
- name: Type check
52+
run: npm run typecheck
3353

34-
- name: Test
35-
run: npm run test:all --ci --coverage --maxWorkers=2
54+
- name: Test all suites in parallel
55+
run: npm-run-all -p test:jest test:swc test:vi test:browser test:examples
3656

3757
- name: Build
3858
run: npm run build

.github/workflows/publish.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,57 @@ name: Publish
22

33
on:
44
release:
5-
# This specifies that the build will be triggered when we publish a release
65
types: [published]
76

87
jobs:
98
publish:
10-
name: 'Publish'
9+
name: Publish to NPM
1110
runs-on: ubuntu-latest
12-
if: "!contains(github.ref_name, 'beta')"
11+
if: ${{ !contains(github.ref_name, 'beta') }}
1312
steps:
14-
- uses: actions/checkout@v2
13+
- name: Checkout repo
14+
uses: actions/checkout@v4
1515

16-
- uses: actions/setup-node@v2
16+
- name: Setup Node.js LTS
17+
uses: actions/setup-node@v4
1718
with:
1819
node-version: 'lts/*'
1920
registry-url: https://registry.npmjs.org/
21+
cache: 'npm'
2022

21-
- name: Install deps and build (with cache)
22-
uses: bahmutov/npm-install@v1
23+
- name: Install dependencies
24+
run: npm ci
2325

24-
- run: npm run build
26+
- name: Build package
27+
run: npm run build
2528

26-
- run: npm publish --access public
29+
- name: Publish to NPM
30+
run: npm publish --access public
2731
env:
28-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
32+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2933

3034
publish_beta:
31-
name: 'Publish beta'
35+
name: Publish beta to NPM
3236
runs-on: ubuntu-latest
33-
if: contains(github.ref_name, 'beta')
37+
if: ${{ contains(github.ref_name, 'beta') }}
3438
steps:
35-
- uses: actions/checkout@v2
39+
- name: Checkout repo
40+
uses: actions/checkout@v4
3641

37-
- uses: actions/setup-node@v2
42+
- name: Setup Node.js LTS
43+
uses: actions/setup-node@v4
3844
with:
3945
node-version: 'lts/*'
4046
registry-url: https://registry.npmjs.org/
47+
cache: 'npm'
4148

42-
- name: Install deps and build (with cache)
43-
uses: bahmutov/npm-install@v1
49+
- name: Install dependencies
50+
run: npm ci
4451

45-
- run: npm run build
52+
- name: Build package
53+
run: npm run build
4654

47-
- run: npm publish --tag beta --access public
55+
- name: Publish beta to NPM
56+
run: npm publish --tag beta --access public
4857
env:
49-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
node_modules
44
.cache
55
.parcel-cache
6+
.eslintcache
7+
*.tsbuildinfo
8+
.jest
69
dist

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint && npm run typecheck

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@
4949
"typecheck": "tsc --noEmit",
5050
"prepare": "tsup"
5151
},
52-
"husky": {
53-
"hooks": {
54-
"pre-commit": "npm run lint"
55-
}
56-
},
52+
5753
"prettier": {
5854
"printWidth": 80,
5955
"semi": true,

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"esModuleInterop": true,
1818
"skipLibCheck": true,
1919
"forceConsistentCasingInFileNames": true,
20-
"noEmit": true
20+
"noEmit": true,
21+
"incremental": true
2122
}
2223
}

0 commit comments

Comments
 (0)