Skip to content

Commit f238ffc

Browse files
committed
feat: automate version tagging from server.json in publish workflow
- Changed trigger from manual version tags to automatic on server.json changes - Added automatic tag creation based on version field in server.json - Implemented tag existence check to prevent duplicate tags
1 parent d2a17e7 commit f238ffc

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

.github/workflows/publish-mcp.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@ name: Publish to MCP Registry
22

33
on:
44
push:
5-
tags: ["v*"] # Triggers on version tags like v1.0.0
5+
branches:
6+
- main
7+
paths:
8+
- 'server.json'
9+
- '.github/workflows/publish-mcp.yml'
610

711
jobs:
812
publish:
913
runs-on: ubuntu-latest
1014
permissions:
11-
id-token: write # Required for OIDC authentication
12-
contents: read
15+
id-token: write
16+
contents: write # Need write permission to create tags
1317

1418
steps:
1519
- name: Checkout code
1620
uses: actions/checkout@v5
21+
with:
22+
fetch-depth: 0 # Fetch all history for tags
1723

1824
- name: Validate server.json
1925
run: |
@@ -23,6 +29,32 @@ jobs:
2329
fi
2430
echo "server.json found and ready for publishing"
2531
32+
- name: Get version from server.json
33+
id: get_version
34+
run: |
35+
VERSION=$(jq -r '.version' server.json)
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "Version from server.json: $VERSION"
38+
39+
- name: Check if tag exists
40+
id: check_tag
41+
run: |
42+
if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
43+
echo "exists=true" >> $GITHUB_OUTPUT
44+
echo "Tag v${{ steps.get_version.outputs.version }} already exists"
45+
else
46+
echo "exists=false" >> $GITHUB_OUTPUT
47+
echo "Tag v${{ steps.get_version.outputs.version }} does not exist"
48+
fi
49+
50+
- name: Create and push tag
51+
if: steps.check_tag.outputs.exists == 'false'
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}"
56+
git push origin "v${{ steps.get_version.outputs.version }}"
57+
2658
- name: Install MCP Publisher
2759
run: |
2860
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher

server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/pitwch/pfx-mcp-server",
88
"source": "github"
99
},
10-
"version": "1.0.0",
10+
"version": "1.0.5",
1111
"remotes": [
1212
{
1313
"type": "streamable-http",

0 commit comments

Comments
 (0)