Skip to content

Commit 78084a7

Browse files
committed
chore: update GitHub Actions workflows to use latest action versions and improve configurations
Signed-off-by: Tiger Kaovilai <[email protected]>
1 parent 9418f67 commit 78084a7

File tree

6 files changed

+148
-11
lines changed

6 files changed

+148
-11
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ jobs:
4040

4141
steps:
4242
- name: Checkout repository
43-
uses: actions/checkout@v3
43+
uses: actions/checkout@v4
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v2
47+
uses: github/codeql-action/init@v3
4848
with:
4949
languages: ${{ matrix.language }}
5050
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below)
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@v2
61+
uses: github/codeql-action/autobuild@v3
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -71,6 +71,6 @@ jobs:
7171
# ./location_of_script_within_repo/buildscript.sh
7272

7373
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@v2
74+
uses: github/codeql-action/analyze@v3
7575
with:
7676
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: 'Checkout Repository'
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
- name: 'Dependency Review'
20-
uses: actions/dependency-review-action@v2
20+
uses: actions/dependency-review-action@v3

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint and Format
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
lint:
12+
name: Lint and Format Check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Use Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '20.x'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Check code formatting
26+
run: npm run format:check || npx prettier --check "**/*.{ts,js,json,yml,md}"
27+
continue-on-error: true
28+
29+
- name: Lint code
30+
run: npm run lint || npx eslint "**/*.{ts,js}"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Multi-Node Testing
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
test:
12+
name: Test on Node.js ${{ matrix.node-version }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [16.x, 18.x, 20.x]
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci || npm install
28+
29+
- name: Build
30+
run: npm run build --if-present
31+
32+
- name: Run unit tests
33+
run: npm run test:unit
34+
35+
- name: Set up Git for E2E tests
36+
run: |
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "Test User"
39+
40+
- name: Run E2E tests
41+
run: npm run test:e2e
42+
# Skip E2E tests on older Node.js versions if they're incompatible
43+
continue-on-error: ${{ matrix.node-version != '20.x' }}

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
8+
jobs:
9+
build:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '20.x'
22+
cache: 'npm'
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build
29+
run: npm run build
30+
31+
- name: Run tests
32+
run: npm test
33+
34+
- name: Extract version from tag
35+
id: get_version
36+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
37+
38+
- name: Generate changelog
39+
id: changelog
40+
uses: jaywcjlove/[email protected]
41+
with:
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Create GitHub Release
45+
id: create_release
46+
uses: softprops/action-gh-release@v1
47+
with:
48+
tag_name: ${{ github.ref }}
49+
name: Release ${{ github.ref_name }}
50+
body: ${{ steps.changelog.outputs.changelog }}
51+
draft: false
52+
prerelease: false
53+
54+
- name: Publish to npm
55+
run: npm publish
56+
env:
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Testing
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- main
49

510
jobs:
611
unit-test:
@@ -9,11 +14,12 @@ jobs:
914
matrix:
1015
node-version: [20.x]
1116
steps:
12-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1318
- name: Use Node.js ${{ matrix.node-version }}
14-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v3
1520
with:
1621
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
1723
- name: Install dependencies
1824
run: npm install
1925
- name: Run Unit Tests
@@ -24,11 +30,12 @@ jobs:
2430
matrix:
2531
node-version: [20.x]
2632
steps:
27-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
2834
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v2
35+
uses: actions/setup-node@v3
3036
with:
3137
node-version: ${{ matrix.node-version }}
38+
cache: 'npm'
3239
- name: Install git
3340
run: |
3441
sudo apt-get update

0 commit comments

Comments
 (0)