Set up package publishing for daily, manual, and release builds (#118)

* Set up a root artifacts folder for all build/test/pack output

Update CI TestResults folder

* Update package Authors and Copyright

* Lower-case extension on README.md

* Move package props to src folder. Use Version prefix and suffix props.

* Set up package publishing for daily, manual, and release builds

* Only run publishing jobs to the modelcontextprotocol/csharp-sdk repo

* Fix condition on docs workflow

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update preview wording in README to apply to the package too

* Verify packaging succeeds in the CI workflow

* Allow a version suffix override in release workflow.

* De-dupe the README between the repo and the NuGet package

* New CI work

* Do not reuse the CI workflow for releases so we can build without tests.

* Add a release process doc

* Fix bug in publishing; needs checkout step. Update comment for publish.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jeff Handley 2025-03-27 15:08:19 -07:00 • committed by GitHub
commit 259f11af8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 161 additions and 238 deletions

View file

@ -8,28 +8,28 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
fail-fast: false
steps:
- uses: actions/checkout@v4
runs-on: ${{ matrix.os }}
steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
dotnet-version: |
9.0.x
8.0.x
# Netfx testing on non-Windows requires mono
# NetFX testing on non-Windows requires mono
- name: Setup Mono
if: runner.os == 'Linux'
run: sudo apt-get install -y mono-devel
@ -38,7 +38,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-everything
@ -48,6 +48,9 @@ jobs:
- name: Build
run: dotnet build --configuration ${{ matrix.configuration }}
- name: Pack
run: dotnet pack --configuration ${{ matrix.configuration }}
- name: Test
run: >-
dotnet test

View file

@ -16,9 +16,11 @@ permissions:
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
publish-docs:
# Only publish from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.repository == 'modelcontextprotocol/csharp-sdk' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
@ -42,4 +44,4 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4

37
.github/workflows/release.md vendored Normal file
View file

@ -0,0 +1,37 @@
# Release Process
The following process is used when publishing new releases to NuGet.org:
1. **Ensure the CI workflow is fully green**
- Some of the integration tests are flaky and require re-running
- Once the state of the branch is known to be good, a release can proceed
- **The release workflow _does not_ run tests**
2. **Create a new Release in GitHub**
- Use the link on the repo home page to [Create a new release](https://github.com/modelcontextprotocol/csharp-sdk/releases/new)
- Click the 'Choose a tag' dropdown button
- Type the name using the `v{major}.{minor}.{patch}-{suffix}` pattern
- Click 'Create new tag: ... on publish'
- Click the 'Target' dropdown button
- Choose the 'Recent Commits' tab
- Select the commit to use for the release, ensuring it's one from above where CI is known to be green
- Click the 'Previous tag' dropdown button
- Choose the previous release to use for generating release notes
- Click the 'Generate release notes button'
- This will add release notes into the Release description
- The generated release notes include what has changed and the list of new contributors
- Verify the Release title
- It will be populated to match the tag name to be created
- This should be retained, using the release title format matching the `v{major}.{minor}.{patch}-{suffix}` format
- Augment the Release description as desired
- This content is presented used on GitHub and is not persisted into any artifacts
- Check the 'Set as a pre-release' button under the release description if appropriate
- Click 'Public release'
3. **Monitor the Release workflow**
- After publishing the release, a workflow will begin for producing the release's build artifacts and publishing the NuGet package to NuGet.org
- If the job fails, troubleshoot and re-run the workflow as needed
- Verify the package version becomes listed on at [https://nuget.org/packages/ModelContextProtocol](https://nuget.org/packages/ModelContextProtocol)
4. **Update the source to increment the version number**
- Immediately after publishing a new release, the [`/src/Directory.Build.Props`](../../src/Directory.Build.props) file needs to be updated to bump the version to the next expected release version

View file

@ -1,20 +1,71 @@
# This workflow is triggered by new releases
# It builds, tests, and publishes to the GitHub NuGet package registry
name: Release package
# Publish new package versions of ModelContextProtocol
#
# Daily and Manual Runs
# - Triggered automatically at 07:00 UTC daily
# - Triggered manually using GitHub Actions workflow_dispatch event
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix set to `ci.{github.run_number}`
# - Package published to GitHub package registry
#
# Official Releases
# - Triggered after a GitHub Release is created
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix applied from /src/Directory.Build.props
# - Package published to GitHub package registry
# - Package published to NuGet.org
# - Version prefix and/or suffix should be updated after each release
name: Release Publishing
on:
schedule:
- cron: '0 7 * * *'
workflow_dispatch:
inputs:
version_suffix_override:
description: Version suffix override
type: string
release:
types: [published]
jobs:
build:
build-all-configs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Build
run: dotnet build --configuration ${{ matrix.configuration }}
- name: Pack
run: dotnet pack --configuration ${{ matrix.configuration }}
build-package:
runs-on: windows-latest
needs: build-all-configs
env:
version_suffix_args: ${{ github.event_name != 'release' && format('--version-suffix "{0}"', inputs.version_suffix_override || format('ci.{0}', github.run_number)) || '' }}
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
@ -23,25 +74,11 @@ jobs:
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"
run: dotnet pack
${{ env.version_suffix_args }}
--configuration Release
--output "${{ github.workspace }}/artifacts/packages"
- name: Upload artifact
uses: actions/upload-artifact@v4
@ -50,20 +87,16 @@ jobs:
name: build-artifacts
path: ${{ github.workspace }}/artifacts
publish:
name: Publish Package
needs: build
publish-package:
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
9.0.x
8.0.x
dotnet-version: 9.0.x
- name: Download build artifacts
uses: actions/download-artifact@v4
@ -75,7 +108,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: NuGet authentication for GitHub
- name: Authenticate to GitHub registry
run: dotnet nuget add source
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
--name "github"
@ -89,3 +122,12 @@ jobs:
--source "github"
--api-key ${{ secrets.GITHUB_TOKEN }}
--skip-duplicate
- name: Publish to NuGet.org (Releases only)
# Only publish to NuGet.org from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.event_name == 'release' && github.repository == 'modelcontextprotocol/csharp-sdk' }}
run: dotnet nuget push
${{github.workspace}}/build-artifacts/packages/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_KEY_MODELCONTEXTPROTOCOL }}
--skip-duplicate