Enhance release workflow to create and upload GitHub releases for tag… #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release single-file (server.Stdio) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| create_release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| publish: | |
| needs: create_release | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| rid: [ linux-x64, win-x64, osx-arm64 ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "9.0.x" | |
| # Note: | |
| # - You can cross-publish for other OSes on ubuntu-latest by changing RID (e.g., win-x64, osx-arm64). | |
| # - macOS binaries produced here are unsigned; signing/notarization must be performed on macOS. | |
| - name: Publish single-file | |
| id: publish | |
| shell: bash | |
| env: | |
| RID: ${{ matrix.rid }} | |
| run: | | |
| set -euo pipefail | |
| PROJ="Server.Stdio/Server.Stdio.csproj" | |
| echo "Publishing $PROJ for RID=$RID" | |
| dotnet publish "$PROJ" -c Release -r "$RID" \ | |
| -p:PublishSingleFile=true \ | |
| -p:SelfContained=true \ | |
| -p:PublishTrimmed=false | |
| TF=$(dotnet msbuild "$PROJ" -getproperty:TargetFramework -nologo -v:quiet) | |
| PUB_DIR="$(dirname "$PROJ")/bin/Release/${TF}/${RID}/publish" | |
| echo "publish_dir=$PUB_DIR" >> "$GITHUB_OUTPUT" | |
| echo "Publish dir: $PUB_DIR" | |
| if [[ "$RID" == win* ]]; then | |
| EXE=$(find "$PUB_DIR" -maxdepth 1 -type f -name "*.exe" | head -n1 || true) | |
| else | |
| EXE=$(find "$PUB_DIR" -maxdepth 1 -type f -perm -u+x | head -n1 || true) | |
| fi | |
| if [ -z "$EXE" ]; then | |
| echo "No executable found in $PUB_DIR" >&2 | |
| ls -la "$PUB_DIR" || true | |
| exit 1 | |
| fi | |
| echo "exe=$EXE" >> "$GITHUB_OUTPUT" | |
| echo "Executable: $EXE" | |
| - name: Prepare asset for Release | |
| id: package | |
| shell: bash | |
| env: | |
| RID: ${{ matrix.rid }} | |
| TAG: ${{ github.ref_name }} | |
| run: | | |
| set -euo pipefail | |
| EXT="" | |
| if [[ "$RID" == win* ]]; then EXT=".exe"; fi | |
| BASENAME="mcp-server-stdio-${TAG}-${RID}${EXT}" | |
| SRC="${{ steps.publish.outputs.exe }}" | |
| DEST="${{ steps.publish.outputs.publish_dir }}/$BASENAME" | |
| cp "$SRC" "$DEST" | |
| echo "asset=$DEST" >> "$GITHUB_OUTPUT" | |
| echo "Packaged asset: $DEST" | |
| - name: Upload asset to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| files: ${{ steps.package.outputs.asset }} | |
| fail_on_unmatched_files: true | |
| - name: Upload executable artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: io-aerosapce-mcp-${{ github.ref_name }}-${{ matrix.rid }} | |
| path: ${{ steps.package.outputs.asset }} | |
| if-no-files-found: error |