-
Notifications
You must be signed in to change notification settings - Fork 4
107 lines (95 loc) · 2.78 KB
/
nodejs.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
102
103
104
105
106
107
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches:
- master
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- run: npm run lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- run: echo "CACHE_KEY=$(cat ./package.json | jq '.config | [.[]] | map(.version, .commit) | @tsv')" >> $GITHUB_ENV
- name: Restore cached build
id: cache
uses: actions/cache@v4
with:
path: dist/swipl
key: ${{ env.CACHE_KEY }}
- name: Full Build
if: steps.cache.outputs.cache-hit != 'true'
run: npm run build
- name: Partial Build
if: steps.cache.outputs.cache-hit == 'true'
run: npm run tsc
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
test:
needs: [ build ]
strategy:
matrix:
node-version: [16.x, 18.x, 19.x, 20.x, 22.x]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- run: npm test
- run: npm run bundle:webpack
release:
if: ${{ github.ref == 'refs/heads/master' }}
needs: [ test, lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: "Create Bundle"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
# The semantic-release command errors if this folder does not exist
mkdir ./bundle
version=$(npx semantic-release --dry-run | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+') || true
if [ $version ]
then
npm run bundle:webpack -- --name=v$version
npm run bundle:latest -- --name=v$version
fi
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release