-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (62 loc) · 1.96 KB
/
Copy pathrelease.yml
File metadata and controls
75 lines (62 loc) · 1.96 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: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish_to_npm:
description: Publish the package to npm after validation
required: false
default: false
type: boolean
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Validate version matches release tag
if: github.event_name == 'release'
shell: bash
run: |
PACKAGE_VERSION=$(node -p "JSON.parse(require('node:fs').readFileSync('package.json', 'utf8')).version")
RELEASE_TAG="${{ github.event.release.tag_name }}"
if [ "v${PACKAGE_VERSION}" != "$RELEASE_TAG" ]; then
echo "Release tag $RELEASE_TAG does not match package version v${PACKAGE_VERSION}"
exit 1
fi
- name: Build MCP server
run: npm run build
- name: Run tests
run: npm test
- name: Pack npm artifact
id: pack
shell: bash
run: |
PACKAGE_TGZ=$(npm pack)
echo "artifact=${PACKAGE_TGZ}" >> "$GITHUB_OUTPUT"
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: inspectra-package
path: ${{ steps.pack.outputs.artifact }}
- name: Publish to npm
if: github.event_name == 'release' || inputs.publish_to_npm == true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --provenance --access public
- name: Attach package to GitHub release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.pack.outputs.artifact }}