|
1 | 1 | on: |
2 | | - push: |
3 | | - branches: |
4 | | - - main |
5 | | - pull_request: |
6 | | - release: |
7 | | - types: [published] |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + release: |
| 8 | + types: [published] |
8 | 9 |
|
9 | 10 | concurrency: |
10 | | - group: ${{ github.workflow }}-${{ github.ref }} |
11 | | - cancel-in-progress: true |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
12 | 13 |
|
13 | 14 | jobs: |
14 | | - build: |
15 | | - runs-on: ubuntu-latest |
16 | | - |
17 | | - steps: |
18 | | - - uses: actions/checkout@v4 |
19 | | - - uses: actions/setup-node@v4 |
20 | | - with: |
21 | | - node-version: 18 |
22 | | - cache: npm |
23 | | - |
24 | | - - run: npm ci |
25 | | - - run: npm run build |
26 | | - - run: npm test |
27 | | - - run: npm run lint |
28 | | - |
29 | | - publish: |
30 | | - runs-on: ubuntu-latest |
31 | | - if: github.event_name == 'release' |
32 | | - environment: release |
33 | | - needs: build |
34 | | - |
35 | | - permissions: |
36 | | - contents: read |
37 | | - id-token: write |
38 | | - |
39 | | - steps: |
40 | | - - uses: actions/checkout@v4 |
41 | | - - uses: actions/setup-node@v4 |
42 | | - with: |
43 | | - node-version: 18 |
44 | | - cache: npm |
45 | | - registry-url: 'https://registry.npmjs.org' |
46 | | - |
47 | | - - run: npm ci |
48 | | - |
49 | | - - run: npm publish --provenance --access public |
50 | | - env: |
51 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 24 |
| 23 | + cache: npm |
| 24 | + |
| 25 | + - run: npm ci |
| 26 | + - run: npm run check |
| 27 | + - run: npm run build |
| 28 | + |
| 29 | + test: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + node-version: [18, 24] |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: ${{ matrix.node-version }} |
| 41 | + cache: npm |
| 42 | + |
| 43 | + - run: npm ci |
| 44 | + - run: npm test |
| 45 | + |
| 46 | + publish: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: github.event_name == 'release' |
| 49 | + environment: release |
| 50 | + needs: [build, test] |
| 51 | + |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + id-token: write |
| 55 | + |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: 24 |
| 61 | + cache: npm |
| 62 | + registry-url: 'https://registry.npmjs.org' |
| 63 | + |
| 64 | + - run: npm ci |
| 65 | + |
| 66 | + - name: Determine npm tag |
| 67 | + id: npm-tag |
| 68 | + run: | |
| 69 | + VERSION=$(node -p "require('./package.json').version") |
| 70 | + # Check if this is a beta release |
| 71 | + if [[ "$VERSION" == *"-beta"* ]]; then |
| 72 | + echo "tag=--tag beta" >> $GITHUB_OUTPUT |
| 73 | + # Check if this release is from a non-main branch (patch/maintenance release) |
| 74 | + elif [[ "${{ github.event.release.target_commitish }}" != "main" ]]; then |
| 75 | + # Use "release-X.Y" as tag for old branch releases (e.g., "release-1.23" for 1.23.x) |
| 76 | + # npm tags are mutable pointers to versions (like "latest" pointing to 1.24.3). |
| 77 | + # Using "release-1.23" means users can `npm install @modelcontextprotocol/sdk@release-1.23` |
| 78 | + # to get the latest patch on that minor version, and the tag updates if we |
| 79 | + # release 1.23.2, 1.23.3, etc. |
| 80 | + # Note: Can't use "v1.23" because npm rejects tags that look like semver ranges. |
| 81 | + MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2) |
| 82 | + echo "tag=--tag release-${MAJOR_MINOR}" >> $GITHUB_OUTPUT |
| 83 | + else |
| 84 | + echo "tag=" >> $GITHUB_OUTPUT |
| 85 | + fi |
| 86 | +
|
| 87 | + - run: npm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }} |
| 88 | + env: |
| 89 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments