Skip to content

Commit 1223c9e

Browse files
committed
feat: add GitHub Actions workflow for publishing DotNetMetadataMcpServer with multi-platform support
1 parent a1767e7 commit 1223c9e

2 files changed

Lines changed: 173 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Publish DotNetMetadataMcpServer
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionOverride:
7+
description: 'Override version (leave empty to use 1.0.0 with auto-incremented patch)'
8+
required: false
9+
type: string
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.set-version.outputs.version }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: '9.0.x'
24+
25+
- name: Set version
26+
id: set-version
27+
run: |
28+
# Extract version prefix from project file
29+
VERSION_PREFIX=$(grep -oP '<VersionPrefix>\K[^<]+' DotNetMetadataMcpServer/DotNetMetadataMcpServer.csproj)
30+
31+
if [ -z "$VERSION_PREFIX" ]; then
32+
# Default version prefix if not found in project file
33+
VERSION_PREFIX="1.0.0"
34+
fi
35+
36+
if [ -n "${{ github.event.inputs.versionOverride }}" ]; then
37+
# Use override version if provided
38+
VERSION="${{ github.event.inputs.versionOverride }}"
39+
else
40+
# Use GitHub run number as patch version
41+
VERSION="${VERSION_PREFIX}.${{ github.run_number }}"
42+
fi
43+
44+
echo "Using version: $VERSION"
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
47+
build-windows:
48+
needs: build
49+
runs-on: windows-latest
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- name: Setup .NET
55+
uses: actions/setup-dotnet@v4
56+
with:
57+
dotnet-version: '9.0.x'
58+
59+
- name: Restore dependencies
60+
run: dotnet restore
61+
62+
- name: Build
63+
run: |
64+
dotnet publish DotNetMetadataMcpServer/DotNetMetadataMcpServer.csproj -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishReadyToRun=true /p:DebugType=None /p:DebugSymbols=false /p:Version=${{ needs.build.outputs.version }} /p:AssemblyVersion=${{ needs.build.outputs.version }}
65+
66+
- name: Create zip archive
67+
run: |
68+
$VERSION = "${{ needs.build.outputs.version }}"
69+
$ZIP_NAME = "DotNetMetadataMcpServer-windows-x64-v$VERSION.zip"
70+
Compress-Archive -Path DotNetMetadataMcpServer/bin/Release/net9.0/win-x64/publish/* -DestinationPath $ZIP_NAME
71+
72+
- name: Upload artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: DotNetMetadataMcpServer-windows-x64
76+
path: DotNetMetadataMcpServer-windows-x64-v${{ needs.build.outputs.version }}.zip
77+
78+
build-linux:
79+
needs: build
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Setup .NET
86+
uses: actions/setup-dotnet@v4
87+
with:
88+
dotnet-version: '9.0.x'
89+
90+
- name: Restore dependencies
91+
run: dotnet restore
92+
93+
- name: Build
94+
run: |
95+
dotnet publish DotNetMetadataMcpServer/DotNetMetadataMcpServer.csproj -c Release -r linux-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishReadyToRun=true /p:DebugType=None /p:DebugSymbols=false /p:Version=${{ needs.build.outputs.version }} /p:AssemblyVersion=${{ needs.build.outputs.version }}
96+
97+
- name: Create zip archive
98+
run: |
99+
VERSION="${{ needs.build.outputs.version }}"
100+
ZIP_NAME="DotNetMetadataMcpServer-linux-x64-v$VERSION.zip"
101+
cd DotNetMetadataMcpServer/bin/Release/net9.0/linux-x64/publish/
102+
chmod +x DotNetMetadataMcpServer
103+
zip -r ../../../../../../$ZIP_NAME *
104+
105+
- name: Upload artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: DotNetMetadataMcpServer-linux-x64
109+
path: DotNetMetadataMcpServer-linux-x64-v${{ needs.build.outputs.version }}.zip
110+
111+
build-macos:
112+
needs: build
113+
runs-on: macos-latest
114+
strategy:
115+
matrix:
116+
architecture: [osx-x64, osx-arm64]
117+
steps:
118+
- name: Checkout code
119+
uses: actions/checkout@v4
120+
121+
- name: Setup .NET
122+
uses: actions/setup-dotnet@v4
123+
with:
124+
dotnet-version: '9.0.x'
125+
126+
- name: Restore dependencies
127+
run: dotnet restore
128+
129+
- name: Build
130+
run: |
131+
dotnet publish DotNetMetadataMcpServer/DotNetMetadataMcpServer.csproj -c Release -r ${{ matrix.architecture }} --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishReadyToRun=true /p:DebugType=None /p:DebugSymbols=false /p:Version=${{ needs.build.outputs.version }} /p:AssemblyVersion=${{ needs.build.outputs.version }}
132+
133+
- name: Create zip archive
134+
run: |
135+
VERSION="${{ needs.build.outputs.version }}"
136+
ZIP_NAME="DotNetMetadataMcpServer-${{ matrix.architecture }}-v$VERSION.zip"
137+
cd DotNetMetadataMcpServer/bin/Release/net9.0/${{ matrix.architecture }}/publish/
138+
zip -r ../../../../../../$ZIP_NAME *
139+
140+
- name: Upload artifact
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: DotNetMetadataMcpServer-${{ matrix.architecture }}
144+
path: DotNetMetadataMcpServer-${{ matrix.architecture }}-v${{ needs.build.outputs.version }}.zip
145+
146+
create-release:
147+
needs: [build, build-windows, build-linux, build-macos]
148+
runs-on: ubuntu-latest
149+
permissions:
150+
contents: write
151+
steps:
152+
- name: Download all artifacts
153+
uses: actions/download-artifact@v4
154+
with:
155+
path: artifacts
156+
157+
- name: Create GitHub Release
158+
uses: softprops/action-gh-release@v1
159+
with:
160+
tag_name: v${{ needs.build.outputs.version }}
161+
name: Release v${{ needs.build.outputs.version }}
162+
files: |
163+
artifacts/DotNetMetadataMcpServer-windows-x64/DotNetMetadataMcpServer-windows-x64-v${{ needs.build.outputs.version }}.zip
164+
artifacts/DotNetMetadataMcpServer-linux-x64/DotNetMetadataMcpServer-linux-x64-v${{ needs.build.outputs.version }}.zip
165+
artifacts/DotNetMetadataMcpServer-osx-x64/DotNetMetadataMcpServer-osx-x64-v${{ needs.build.outputs.version }}.zip
166+
artifacts/DotNetMetadataMcpServer-osx-arm64/DotNetMetadataMcpServer-osx-arm64-v${{ needs.build.outputs.version }}.zip
167+
draft: false
168+
prerelease: false
169+
env:
170+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

DotNetMetadataMcpServer/DotNetMetadataMcpServer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<RootNamespace>DotNetMetadataMcpServer</RootNamespace>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<NoWarn>CS1591</NoWarn> <!-- Disable warning CS1591: Missing XML comment for publicly visible type or member -->
11+
<VersionPrefix>1.0</VersionPrefix>
12+
<AssemblyVersion>$(VersionPrefix).1</AssemblyVersion>
13+
<FileVersion>$(VersionPrefix).1</FileVersion>
1114
</PropertyGroup>
1215

1316
<ItemGroup>

0 commit comments

Comments
 (0)