Skip to content

Commit 2bb7f47

Browse files
authored
feat: add workflow to publish v1.x releases on tag push (#1367)
1 parent 1014d9f commit 2bb7f47

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

.github/workflows/release-v1x.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Publish v1.x releases when a v1.* tag is pushed
2+
# This allows releasing from the v1.x branch without switching GitHub's default branch
3+
#
4+
# Automatic (latest v1.x):
5+
# git checkout v1.x
6+
# npm version patch # bumps version and creates tag
7+
# git push origin v1.x --tags
8+
#
9+
# Manual (for older minor versions like v1.23.x):
10+
# 1. Create a release branch: git checkout -b release/1.23 v1.23.1
11+
# 2. Apply your fixes
12+
# 3. Bump version: npm version patch # creates v1.23.2 tag
13+
# 4. Push: git push origin release/1.23 --tags
14+
# 5. Run this workflow manually from GitHub Actions, specifying the tag
15+
#
16+
# The workflow will automatically build, test, and publish to npm.
17+
18+
name: Publish v1.x
19+
20+
on:
21+
push:
22+
tags:
23+
- 'v1.*'
24+
workflow_dispatch:
25+
inputs:
26+
ref:
27+
description: 'Git ref to release (tag, e.g., v1.23.2)'
28+
required: true
29+
type: string
30+
31+
permissions:
32+
contents: read
33+
34+
concurrency: ${{ github.workflow }}-${{ inputs.ref || github.ref }}
35+
36+
jobs:
37+
build:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
ref: ${{ inputs.ref || github.ref }}
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: 24
47+
cache: npm
48+
49+
- run: npm ci
50+
- run: npm run check
51+
- run: npm run build
52+
53+
test:
54+
runs-on: ubuntu-latest
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
node-version: [18, 24]
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
with:
63+
ref: ${{ inputs.ref || github.ref }}
64+
- uses: actions/setup-node@v4
65+
with:
66+
node-version: ${{ matrix.node-version }}
67+
cache: npm
68+
69+
- run: npm ci
70+
- run: npm test
71+
72+
publish:
73+
runs-on: ubuntu-latest
74+
needs: [build, test]
75+
environment: release
76+
77+
permissions:
78+
contents: read
79+
id-token: write
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
with:
84+
ref: ${{ inputs.ref || github.ref }}
85+
- uses: actions/setup-node@v4
86+
with:
87+
node-version: 24
88+
cache: npm
89+
registry-url: 'https://registry.npmjs.org'
90+
91+
- run: npm ci
92+
93+
- name: Determine npm tag
94+
id: npm-tag
95+
run: |
96+
VERSION=$(node -p "require('./package.json').version")
97+
# Use "release-X.Y" as tag for v1.x releases
98+
# This allows users to install specific minor versions:
99+
# npm install @modelcontextprotocol/sdk@release-1.25
100+
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
101+
echo "tag=release-${MAJOR_MINOR}" >> $GITHUB_OUTPUT
102+
103+
- run: npm publish --provenance --access public --tag ${{ steps.npm-tag.outputs.tag }}
104+
env:
105+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,48 @@ pnpm --filter @modelcontextprotocol/examples-server exec tsx src/simpleStreamabl
6060
pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleStreamableHttp.ts
6161
```
6262

63+
## Releasing v1.x Patches
64+
65+
The `v1.x` branch contains the stable v1 release. To release a patch:
66+
67+
### Latest v1.x (e.g., v1.25.3)
68+
69+
```bash
70+
git checkout v1.x
71+
git pull origin v1.x
72+
# Apply your fix or cherry-pick commits
73+
npm version patch # Bumps version and creates tag (e.g., v1.25.3)
74+
git push origin v1.x --tags
75+
```
76+
77+
The tag push automatically triggers the release workflow.
78+
79+
### Older minor versions (e.g., v1.23.2)
80+
81+
For patching older minor versions that aren't on the `v1.x` branch:
82+
83+
```bash
84+
# 1. Create a release branch from the last release tag
85+
git checkout -b release/1.23 v1.23.1
86+
87+
# 2. Apply your fixes (cherry-pick or manual)
88+
git cherry-pick <commit-hash>
89+
90+
# 3. Bump version and push
91+
npm version patch # Creates v1.23.2 tag
92+
git push origin release/1.23 --tags
93+
```
94+
95+
Then manually trigger the "Publish v1.x" workflow from [GitHub Actions](https://github.com/modelcontextprotocol/typescript-sdk/actions/workflows/release-v1x.yml), specifying the tag (e.g., `v1.23.2`).
96+
97+
### npm Tags
98+
99+
v1.x releases are published with `release-X.Y` npm tags (e.g., `release-1.25`), not `latest`. To install a specific minor version:
100+
101+
```bash
102+
npm install @modelcontextprotocol/sdk@release-1.25
103+
```
104+
63105
## Code of Conduct
64106

65107
This project follows our [Code of Conduct](CODE_OF_CONDUCT.md). Please review it before contributing.

0 commit comments

Comments
 (0)