Skip to content

Commit dcb5670

Browse files
author
xychen
committed
Build and publish JSON schema
1 parent 13ae218 commit dcb5670

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/build.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ on:
22
push:
33
pull_request:
44

5+
permissions:
6+
contents: write
7+
id-token: write
8+
pages: write
9+
510
jobs:
611
build:
712
strategy:
@@ -54,6 +59,13 @@ jobs:
5459
name: commands-mcp_${{ matrix.name }}
5560
path: target/${{ matrix.target }}/release/commands-mcp${{ matrix.suffix }}
5661

62+
- name: Archive schema.json
63+
uses: actions/upload-artifact@v4
64+
if: matrix.name == 'linux-x64'
65+
with:
66+
name: schema
67+
path: commands.schema.json
68+
5769
pack-npm:
5870
runs-on: ubuntu-latest
5971
needs: build
@@ -87,3 +99,52 @@ jobs:
8799
with:
88100
name: npm-tarball
89101
path: ${{ steps.pack.outputs.tarball }}
102+
103+
schema-pack:
104+
runs-on: ubuntu-latest
105+
needs: build
106+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/v'))
107+
steps:
108+
- name: Checkout schema branch
109+
uses: actions/checkout@v4
110+
with:
111+
ref: schema
112+
path: schema
113+
fetch-depth: 0
114+
115+
- name: Download schema.json
116+
uses: actions/download-artifact@v4
117+
with:
118+
name: schema
119+
120+
- name: Commit and push
121+
run: |
122+
mv -v commands.schema.json schema/${{ github.ref_name }}.json
123+
cd schema
124+
git config --local user.name "xychen"
125+
git config --local user.email "[email protected]"
126+
if [[ -z "$(git status --porcelain)" ]]; then
127+
echo "No changes to commit"
128+
else
129+
git add ${{ github.ref_name }}.json
130+
git commit -m "Update schema for ${{ github.ref_name }}"
131+
git push
132+
fi
133+
134+
- name: Upload Pages artifact
135+
uses: actions/upload-pages-artifact@v3
136+
with:
137+
path: ${{ github.workspace }}
138+
139+
schema-deploy:
140+
runs-on: ubuntu-latest
141+
needs: schema-pack
142+
143+
environment:
144+
name: github-pages
145+
url: ${{ steps.deploy.outputs.page_url }}
146+
147+
steps:
148+
- name: Deploy to GitHub Pages
149+
uses: actions/deploy-pages@v4
150+
id: deploy

0 commit comments

Comments
 (0)