From 0309dfc447db724118fd4e3b9112a54f0bc7de1e Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Fri, 21 Mar 2025 12:46:45 -0700 Subject: [PATCH] Add a release workflow for package build/publishing (#51) * Add a release workflow for package build/publishing * Use Windows. Set the fetch depth. Fix build/test/pack for output folder. Upload the artifact. --- .github/workflows/release.yml | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..22140a1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,91 @@ +# This workflow is triggered by new releases +# It builds, tests, and publishes to the GitHub NuGet package registry +name: Release package + +on: + release: + types: [published] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 9.0.x + 8.0.x + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies for tests + run: npm install @modelcontextprotocol/server-everything + + - name: Install dependencies for tests + run: npm install @modelcontextprotocol/server-memory + + - name: Build + run: dotnet build --configuration Release + + - name: Test + run: dotnet test --configuration Release --no-build --filter '(Execution!=Manual)' + + - name: Pack + run: dotnet pack --configuration Release --output "${{ github.workspace }}/artifacts/packages" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: build-artifacts + path: ${{ github.workspace }}/artifacts + + publish: + name: Publish Package + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 9.0.x + 8.0.x + + - name: Download build artifacts + uses: actions/download-artifact@v4 + + - name: Upload release asset + if: github.event_name == 'release' + run: gh release upload ${{ github.event.release.tag_name }} + ${{ github.workspace }}/build-artifacts/packages/*.*nupkg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: NuGet authentication for GitHub + run: dotnet nuget add source + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" + --name "github" + --username ${{ github.actor }} + --password ${{ secrets.GITHUB_TOKEN }} + --store-password-in-clear-text + + - name: Publish to GitHub NuGet package registry + run: dotnet nuget push + ${{github.workspace}}/build-artifacts/packages/*.nupkg + --source "github" + --api-key ${{ secrets.GITHUB_TOKEN }} + --skip-duplicate