Skip to content

Commit 7e8a470

Browse files
ci(release): add tag publish workflow
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 4a5b02a commit 7e8a470

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/publish-npm.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish NPM Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "24.x"
23+
registry-url: "https://registry.npmjs.org"
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: "10"
29+
30+
- name: Ensure npm supports trusted publishing
31+
run: npm install -g npm@latest
32+
33+
- name: Check tag matches package version
34+
id: version
35+
run: |
36+
PKG_VERSION=$(node -p "require('./packages/yapi-mcp/package.json').version")
37+
if [ "v$PKG_VERSION" != "${GITHUB_REF_NAME}" ]; then
38+
echo "match=false" >> $GITHUB_OUTPUT
39+
echo "Skip publish: tag ${GITHUB_REF_NAME} does not match v${PKG_VERSION}."
40+
exit 0
41+
fi
42+
echo "match=true" >> $GITHUB_OUTPUT
43+
44+
- name: Install dependencies
45+
if: steps.version.outputs.match == 'true'
46+
run: pnpm -C packages/yapi-mcp install --frozen-lockfile
47+
48+
- name: Build package
49+
if: steps.version.outputs.match == 'true'
50+
run: pnpm -C packages/yapi-mcp build
51+
52+
- name: Publish to npm
53+
if: steps.version.outputs.match == 'true'
54+
working-directory: packages/yapi-mcp
55+
run: npm publish

0 commit comments

Comments
 (0)