* 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>
133 lines
4 KiB
YAML
133 lines
4 KiB
YAML
# 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-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
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v2
|
|
with:
|
|
dotnet-version: |
|
|
9.0.x
|
|
8.0.x
|
|
|
|
- name: Pack
|
|
run: dotnet pack
|
|
${{ env.version_suffix_args }}
|
|
--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-package:
|
|
needs: build-package
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v2
|
|
with:
|
|
dotnet-version: 9.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: Authenticate to GitHub registry
|
|
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
|
|
|
|
- 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
|