|
| 1 | +# This workflow is triggered by new releases |
| 2 | +# It builds, tests, and publishes to the GitHub NuGet package registry |
| 3 | +name: Release package |
| 4 | + |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + |
| 12 | + runs-on: windows-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 18 | + |
| 19 | + - name: Setup .NET |
| 20 | + uses: actions/setup-dotnet@v2 |
| 21 | + with: |
| 22 | + dotnet-version: | |
| 23 | + 9.0.x |
| 24 | + 8.0.x |
| 25 | +
|
| 26 | + - name: Set up Node.js |
| 27 | + uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: '20' |
| 30 | + |
| 31 | + - name: Install dependencies for tests |
| 32 | + run: npm install @modelcontextprotocol/server-everything |
| 33 | + |
| 34 | + - name: Install dependencies for tests |
| 35 | + run: npm install @modelcontextprotocol/server-memory |
| 36 | + |
| 37 | + - name: Build |
| 38 | + run: dotnet build --configuration Release |
| 39 | + |
| 40 | + - name: Test |
| 41 | + run: dotnet test --configuration Release --no-build --filter '(Execution!=Manual)' |
| 42 | + |
| 43 | + - name: Pack |
| 44 | + run: dotnet pack --configuration Release --output "${{ github.workspace }}/artifacts/packages" |
| 45 | + |
| 46 | + - name: Upload artifact |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + if: ${{ !cancelled() }} |
| 49 | + with: |
| 50 | + name: build-artifacts |
| 51 | + path: ${{ github.workspace }}/artifacts |
| 52 | + |
| 53 | + publish: |
| 54 | + name: Publish Package |
| 55 | + needs: build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v2 |
| 60 | + |
| 61 | + - name: Setup .NET |
| 62 | + uses: actions/setup-dotnet@v2 |
| 63 | + with: |
| 64 | + dotnet-version: | |
| 65 | + 9.0.x |
| 66 | + 8.0.x |
| 67 | +
|
| 68 | + - name: Download build artifacts |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + |
| 71 | + - name: Upload release asset |
| 72 | + if: github.event_name == 'release' |
| 73 | + run: gh release upload ${{ github.event.release.tag_name }} |
| 74 | + ${{ github.workspace }}/build-artifacts/packages/*.*nupkg |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + - name: NuGet authentication for GitHub |
| 79 | + run: dotnet nuget add source |
| 80 | + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
| 81 | + --name "github" |
| 82 | + --username ${{ github.actor }} |
| 83 | + --password ${{ secrets.GITHUB_TOKEN }} |
| 84 | + --store-password-in-clear-text |
| 85 | + |
| 86 | + - name: Publish to GitHub NuGet package registry |
| 87 | + run: dotnet nuget push |
| 88 | + ${{github.workspace}}/build-artifacts/packages/*.nupkg |
| 89 | + --source "github" |
| 90 | + --api-key ${{ secrets.GITHUB_TOKEN }} |
| 91 | + --skip-duplicate |
0 commit comments