Skip to content

Commit d70d6ff

Browse files
Add CI/CD workflows for building and releasing single-file executables
1 parent 76b9220 commit d70d6ff

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: "9.0.x"
19+
20+
- name: Restore
21+
run: dotnet restore
22+
23+
- name: Build (Release)
24+
run: dotnet build --no-restore -c Release

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release single-file (server.Stdio)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
rid:
7+
description: ".NET Runtime Identifier (e.g., linux-x64, win-x64, osx-arm64)"
8+
required: true
9+
default: "linux-x64"
10+
push:
11+
tags:
12+
- "v*"
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: "9.0.x"
25+
26+
# Note:
27+
# - You can cross-publish for other OSes on ubuntu-latest by changing RID (e.g., win-x64, osx-arm64).
28+
# - macOS binaries produced here are unsigned; signing/notarization must be performed on macOS.
29+
- name: Publish single-file
30+
id: publish
31+
shell: bash
32+
env:
33+
RID: ${{ github.event.inputs.rid || 'linux-x64' }}
34+
run: |
35+
set -euo pipefail
36+
PROJ="Server.Stdio/Server.Stdio.csproj"
37+
echo "Publishing $PROJ for RID=$RID"
38+
39+
dotnet publish "$PROJ" -c Release -r "$RID" \
40+
-p:PublishSingleFile=true \
41+
-p:SelfContained=true \
42+
-p:PublishTrimmed=false
43+
44+
TF=$(dotnet msbuild "$PROJ" -getproperty:TargetFramework -nologo -v:quiet)
45+
PUB_DIR="$(dirname "$PROJ")/bin/Release/${TF}/${RID}/publish"
46+
echo "publish_dir=$PUB_DIR" >> "$GITHUB_OUTPUT"
47+
echo "Publish dir: $PUB_DIR"
48+
49+
if [[ "$RID" == win* ]]; then
50+
EXE=$(find "$PUB_DIR" -maxdepth 1 -type f -name "*.exe" | head -n1 || true)
51+
else
52+
EXE=$(find "$PUB_DIR" -maxdepth 1 -type f -perm -u+x | head -n1 || true)
53+
fi
54+
55+
if [ -z "$EXE" ]; then
56+
echo "No executable found in $PUB_DIR" >&2
57+
ls -la "$PUB_DIR" || true
58+
exit 1
59+
fi
60+
echo "exe=$EXE" >> "$GITHUB_OUTPUT"
61+
echo "Executable: $EXE"
62+
63+
- name: Upload executable artifact
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: io-aerosapce-mcp-${{ github.ref_name }}-${{ github.event.inputs.rid || 'linux-x64' }}
67+
path: ${{ steps.publish.outputs.exe }}
68+
if-no-files-found: error

docs/CI-CD.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CI/CD
2+
3+
- CI: Builds the repository on every push and PR (.github/workflows/ci.yml).
4+
- CD: Publishes a single-file executable for `server.Stdio` and uploads only that file as an artifact (.github/workflows/release.yml).
5+
6+
How to trigger deployment:
7+
- Tag-based: push a tag like `v1.0.0`.
8+
- Manual: Actions → "Release single-file (server.Stdio)" → Run workflow and choose a RID (default `linux-x64`).
9+
10+
Change target runtime:
11+
- Provide a different RID when running the workflow (examples: `linux-x64`, `win-x64`, `osx-arm64`).
12+
13+
Result:
14+
- Artifact name: `io-aerosapce-mcp-<tag or branch>-<RID>`
15+
- Contains only the produced executable.
16+
17+
Note on cross-publishing (ubuntu-latest):
18+
- Yes, you can generate Windows (.exe) or macOS binaries from Ubuntu by setting RID to `win-x64` or `osx-arm64`.
19+
- macOS outputs will be unsigned; signing/notarization must happen on macOS if required.
20+
21+
Local single-file publish examples:
22+
```bash
23+
# Linux
24+
dotnet publish ./Server.Stdio/Server.Stdio.csproj -c Release -r linux-x64 -p:PublishSingleFile=true -p:SelfContained=true
25+
# Windows
26+
dotnet publish ./Server.Stdio/Server.Stdio.csproj -c Release -r win-x64 -p:PublishSingleFile=true -p:SelfContained=true
27+
# macOS (unsigned)
28+
dotnet publish ./Server.Stdio/Server.Stdio.csproj -c Release -r osx-arm64 -p:PublishSingleFile=true -p:SelfContained=true
29+
```

0 commit comments

Comments
 (0)