-
Notifications
You must be signed in to change notification settings - Fork 106
76 lines (63 loc) · 2.14 KB
/
ci.yml
File metadata and controls
76 lines (63 loc) · 2.14 KB
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
name: CI
on: [push, pull_request]
jobs:
build:
name: Build & test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, v22.20.0, '*']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: 'npm'
cache-dependency-path: 'package.json'
- run: npm install
- run: npm run ci-tests
env:
# Node v22+ needs no strip-types (because we use ts-node for full TS instead)
NODE_OPTIONS: >-
${{ (!startsWith(matrix.node-version, '20') && '--no-experimental-strip-types') || '' }}
# We log performance test results to Posthog to track trends:
POSTHOG_PERF_API_KEY: ${{ secrets.POSTHOG_PERF_API_KEY }}
- name: Deploy docs
if: github.ref == 'refs/heads/main' && matrix.node-version == 'v22.20.0'
uses: JamesIves/github-pages-deploy-action@v4
with:
single-commit: true
branch: gh-pages
folder: typedoc
publish:
name: Publish to npm
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: npm
url: https://www.npmjs.com/package/mockttp
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'v22.20.0'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: 'package.json'
- run: npm install
- run: npm run build
- name: Verify tag matches package.json version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Error: Tag version (v$TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
echo "✓ Tag version matches package.json version: $PACKAGE_VERSION"
- run: npm publish