Release version 0.1.2.1 #2
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: Publish to NuGet | |
| on: | |
| push: | |
| branches: [br_release] | |
| permissions: | |
| contents: write | |
| env: | |
| DRY_RUN: 'false' | |
| jobs: | |
| download-binaries: | |
| name: Download gopher-orch binaries | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| version_tag: ${{ steps.version.outputs.version_tag }} | |
| dry_run: ${{ steps.version.outputs.dry_run }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Read version from csproj | |
| id: version | |
| run: | | |
| VERSION=$(grep "<Version>" src/GopherMcp/GopherMcp.csproj | sed -E 's/.*<Version>([^<]+)<\/Version>.*/\1/' | head -1) | |
| VERSION_TAG="v${VERSION}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT | |
| echo "dry_run=${{ env.DRY_RUN }}" >> $GITHUB_OUTPUT | |
| echo "Version: ${VERSION}" | |
| - name: Download all release assets | |
| env: | |
| GH_TOKEN: ${{ secrets.GOPHER_ORCH_TOKEN }} | |
| run: | | |
| gh release download ${{ steps.version.outputs.version_tag }} \ | |
| -R GopherSecurity/gopher-orch \ | |
| -D downloads | |
| mkdir -p artifacts/linux-x64 artifacts/linux-arm64 | |
| mkdir -p artifacts/darwin-x64 artifacts/darwin-arm64 | |
| mkdir -p artifacts/win32-x64 artifacts/win32-arm64 | |
| tar -xzf downloads/libgopher-orch-linux-x64.tar.gz -C artifacts/linux-x64 | |
| tar -xzf downloads/libgopher-orch-linux-arm64.tar.gz -C artifacts/linux-arm64 | |
| tar -xzf downloads/libgopher-orch-macos-x64.tar.gz -C artifacts/darwin-x64 | |
| tar -xzf downloads/libgopher-orch-macos-arm64.tar.gz -C artifacts/darwin-arm64 | |
| unzip -o downloads/libgopher-orch-windows-x64.zip -d artifacts/win32-x64 | |
| unzip -o downloads/libgopher-orch-windows-arm64.zip -d artifacts/win32-arm64 | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-binaries | |
| path: artifacts/ | |
| retention-days: 1 | |
| build-and-test: | |
| name: Build and Test (${{ matrix.os }}) | |
| needs: download-binaries | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux-x64 | |
| lib_ext: "so" | |
| - os: macos-14 | |
| platform: darwin-arm64 | |
| lib_ext: "dylib" | |
| - os: macos-15 | |
| platform: darwin-x64 | |
| lib_ext: "dylib" | |
| - os: windows-latest | |
| platform: win32-x64 | |
| lib_ext: "dll" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '6.0.x' | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: native-binaries | |
| path: artifacts/ | |
| - name: Copy native libraries | |
| shell: bash | |
| run: | | |
| mkdir -p native/lib | |
| if [ -d "artifacts/${{ matrix.platform }}/lib" ]; then | |
| cp -P artifacts/${{ matrix.platform }}/lib/*.${{ matrix.lib_ext }}* native/lib/ 2>/dev/null || true | |
| fi | |
| cp -P artifacts/${{ matrix.platform }}/*.${{ matrix.lib_ext }}* native/lib/ 2>/dev/null || true | |
| - name: Build and Test | |
| shell: bash | |
| run: | | |
| dotnet restore | |
| dotnet build --no-restore -c Release | |
| dotnet test --no-build -c Release --verbosity normal | |
| - name: Package | |
| run: dotnet pack --no-build -c Release -o ./artifacts | |
| publish: | |
| name: Publish to NuGet | |
| needs: [download-binaries, build-and-test] | |
| runs-on: ubuntu-latest | |
| if: needs.download-binaries.outputs.dry_run != 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '6.0.x' | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: native-binaries | |
| path: artifacts/ | |
| - name: Copy native libraries | |
| run: | | |
| mkdir -p native/lib | |
| cp -P artifacts/linux-x64/lib/*.so* native/lib/ 2>/dev/null || true | |
| cp -P artifacts/linux-x64/*.so* native/lib/ 2>/dev/null || true | |
| - name: Build and Pack | |
| run: | | |
| dotnet restore | |
| dotnet build --no-restore -c Release | |
| dotnet pack --no-build -c Release -o ./nupkgs | |
| - name: Publish to NuGet | |
| run: dotnet nuget push ./nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| publish-dry-run: | |
| name: Publish (Dry Run) | |
| needs: [download-binaries, build-and-test] | |
| runs-on: ubuntu-latest | |
| if: needs.download-binaries.outputs.dry_run == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Show package info | |
| run: | | |
| echo "=== Would publish to NuGet ===" | |
| echo "PackageId: GopherMcp" | |
| echo "Version: ${{ needs.download-binaries.outputs.version }}" | |
| create-release: | |
| name: Create GitHub Release | |
| needs: [download-binaries, publish] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate release notes | |
| run: | | |
| VERSION="${{ needs.download-binaries.outputs.version }}" | |
| VERSION_TAG="${{ needs.download-binaries.outputs.version_tag }}" | |
| cat > RELEASE_NOTES.md << 'EOF' | |
| ## Installation | |
| ### NuGet Package Manager | |
| ```powershell | |
| Install-Package GopherMcp -Version VERSION_PLACEHOLDER | |
| ``` | |
| ### .NET CLI | |
| ```bash | |
| dotnet add package GopherMcp --version VERSION_PLACEHOLDER | |
| ``` | |
| ### PackageReference | |
| ```xml | |
| <PackageReference Include="GopherMcp" Version="VERSION_PLACEHOLDER" /> | |
| ``` | |
| ## What's Changed | |
| EOF | |
| sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" RELEASE_NOTES.md | |
| if [ -f "CHANGELOG.md" ]; then | |
| sed -n '/^## \['"${VERSION}"'\]/,/^## \[/p' CHANGELOG.md | \ | |
| grep -v "^## \[" | head -50 >> RELEASE_NOTES.md || true | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.download-binaries.outputs.version_tag }} | |
| name: GopherMcp C# SDK ${{ needs.download-binaries.outputs.version_tag }} | |
| body_path: RELEASE_NOTES.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |