Skip to content

Commit 42e2c87

Browse files
liplus-lin-layLin & Layclaude
authored
feat(cd): add npm publish step to CD workflow (#69)
タグ push 時に npm publish を自動実行するステップを追加。 タグ名からバージョンを同期し、プレリリースタグは next dist-tag で公開する。 Refs #65 Co-authored-by: Lin & Lay <liplus.lin.lay@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aef2c1b commit 42e2c87

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

.github/workflows/cd.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,28 @@ jobs:
3939
gh release create "${{ github.ref_name }}" dist/*.mcpb \
4040
--title "${{ github.ref_name }}" \
4141
--generate-notes
42+
43+
npm-publish:
44+
runs-on: ubuntu-latest
45+
needs: release
46+
steps:
47+
- uses: actions/checkout@v6
48+
- uses: actions/setup-node@v6
49+
with:
50+
node-version: "24"
51+
registry-url: "https://registry.npmjs.org"
52+
- run: npm ci
53+
working-directory: mcp-server
54+
- name: Sync version from git tag
55+
working-directory: mcp-server
56+
run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version
57+
- name: Publish to npm
58+
working-directory: mcp-server
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
run: |
62+
TAG="latest"
63+
if echo "${GITHUB_REF_NAME}" | grep -qE '[-]'; then
64+
TAG="next"
65+
fi
66+
npm publish --access public --tag "$TAG"

docs/0-requirements.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ Node.js >= 18.0.0 が必要。
197197
|---------|--------|------|
198198
| `v*` タグ push | build-mcpb | `mcpb pack` で .mcpb 生成 |
199199
| `v*` タグ push | release | GitHub Release 作成 + .mcpb 添付 |
200+
| `v*` タグ push | npm-publish | npm レジストリに公開 |
200201

201202
リリースフロー:
202-
1. `npm version patch/minor/major` で package.json 更新 + `v*` タグ作成
203-
2. `git push origin main --tags` でタグ push
204-
3. CD が自動実行: .mcpb 生成 → release 作成 → .mcpb 添付
203+
1. `v*` タグを push する
204+
2. CD が自動実行: .mcpb 生成 → release 作成 → .mcpb 添付 → npm publish
205+
3. npm publish 時にタグ名から自動でバージョンを同期する(package.json の手動更新不要)
206+
4. プレリリースタグ(`-` を含む)は `next` dist-tag で公開、正式リリースは `latest` で公開
205207

206-
バージョン管理は npm (package.json) が正。manifest.json のバージョンも一致させる。
208+
manifest.json のバージョンも一致させる。
207209

208210
## Infrastructure
209211

0 commit comments

Comments
 (0)