-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (50 loc) · 1.56 KB
/
Copy pathnpm.yml
File metadata and controls
61 lines (50 loc) · 1.56 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
name: Build&Publish
on:
push:
branches: [ main ]
pull_request:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
- name: Install latest npm (trusted publishing requires >=11.5.1)
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Type check (src + tests)
run: npm run build:check
- name: Lint code
run: npm run lint
- name: Run tests
run: npm run test:ci
# Only build and publish on push to main and release events
- name: Build and publish (main branch only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
NPM_PACKAGE_VERSION=$(node -e "const fs = require('fs'); console.log(JSON.parse(fs.readFileSync('package.json')).version);")
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
npm --no-git-tag-version version $NPM_PACKAGE_VERSION-rc.$SHORT_SHA
npm publish --access public --tag dev
env:
CI: true
GITHUB_SHA: ${{ github.sha }}
- name: Publish on release
if: github.event_name == 'release'
run: |
npm publish --access public
env:
CI: true