-
Notifications
You must be signed in to change notification settings - Fork 27
109 lines (88 loc) · 2.78 KB
/
ci.yml
File metadata and controls
109 lines (88 loc) · 2.78 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
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
108
109
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Build
run: npm run build
- name: Run tests
run: npm test
- name: Check for vulnerabilities
run: npm audit --audit-level=high
continue-on-error: true
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- run: npm ci
- name: Type check
run: npm run typecheck
publish:
needs: [build, typecheck]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Check if version already published
id: version_check
run: |
LOCAL_VERSION=$(node -p "require('./package.json').version")
echo "local_version=$LOCAL_VERSION" >> $GITHUB_OUTPUT
# Check if this version exists on npm
NPM_VERSION=$(npm view omnisql-mcp version 2>/dev/null || echo "0.0.0")
echo "npm_version=$NPM_VERSION" >> $GITHUB_OUTPUT
if [ "$LOCAL_VERSION" = "$NPM_VERSION" ]; then
echo "should_publish=false" >> $GITHUB_OUTPUT
echo "Version $LOCAL_VERSION already published, skipping"
else
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "Will publish $LOCAL_VERSION (npm has $NPM_VERSION)"
fi
- name: Publish to npm (OIDC trusted publishing)
if: steps.version_check.outputs.should_publish == 'true'
run: npm publish --provenance --access public
- name: Create git tag
if: steps.version_check.outputs.should_publish == 'true'
run: |
VERSION=${{ steps.version_check.outputs.local_version }}
git tag "v${VERSION}"
git push origin "v${VERSION}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}