Skip to content

feat(ci): 添加发布工作流支持NuGet和GitHub Packages#177

Merged
GeWuYou merged 3 commits into
mainfrom
feat/ci-publish-workflow-nuget-github
Apr 5, 2026
Merged

feat(ci): 添加发布工作流支持NuGet和GitHub Packages#177
GeWuYou merged 3 commits into
mainfrom
feat/ci-publish-workflow-nuget-github

Conversation

@GeWuYou

@GeWuYou GeWuYou commented Apr 5, 2026

Copy link
Copy Markdown
Owner
  • 实现自动构建和打包功能,支持标签触发
  • 集成NuGet.org和GitHub Packages双重发布机制
  • 添加许可证合规性检查和SBOM文件生成
  • 实现GitHub Release自动创建和资产上传
  • 配置OIDC身份验证和临时API密钥管理
  • 添加包重复上传检测和跳过功能

Summary by Sourcery

将发布工作流拆分为多个独立的作业:构建/打包、发布到 NuGet.org 和 GitHub Packages,以及创建 GitHub Release,这些作业都由标签触发,并通过共享的构件和输出进行串联。

新功能:

  • 在 CI 工作流中,支持将构建好的 NuGet 包发布到 GitHub Packages,除了发布到 NuGet.org 之外。
  • 基于构建作业推断出的版本输出,自动创建 GitHub Release,并附加构建的包文件以及许可证/SBOM 合规性构件。

增强改进:

  • 重构发布工作流为并行作业,这些作业复用已上传的构件而不是重新构建,从而提升隔离性和效率。
  • 收紧各作业的权限范围,在保持基于 OIDC 的 NuGet 发布认证的前提下,仅授予所需的最小权限范围。
Original summary in English

Summary by Sourcery

Split the publish workflow into separate jobs for building/packing, publishing to NuGet.org and GitHub Packages, and creating a GitHub Release, all triggered by tags and wired through shared artifacts and outputs.

New Features:

  • Support publishing built NuGet packages to GitHub Packages in addition to NuGet.org within the CI workflow.
  • Automatically create GitHub Releases that attach built package files and license/SBOM compliance artifacts using the build job's inferred version output.

Enhancements:

  • Refactor the publish workflow into parallel jobs that reuse uploaded artifacts instead of rebuilding, improving isolation and efficiency.
  • Tighten job-specific permissions to use minimal required scopes while keeping OIDC-based authentication for NuGet publishing.

GeWuYou added 2 commits April 5, 2026 18:49
- 实现自动构建和打包功能,支持标签触发
- 集成NuGet.org和GitHub Packages双重发布机制
- 添加许可证合规性检查和SBOM文件生成
- 实现GitHub Release自动创建和资产上传
- 配置OIDC身份验证和临时API密钥管理
- 添加包重复上传检测和跳过功能
- 移除了 NuGet.org 和 GitHub Packages 发布状态检查
- 简化了发布工作流的输出信息
- 更新了合规性检查部分的格式
@deepsource-io

deepsource-io Bot commented Apr 5, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in a22e522...1e092c0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Apr 5, 2026 12:23p.m. Review ↗
Secrets Apr 5, 2026 12:23p.m. Review ↗

@sourcery-ai

sourcery-ai Bot commented Apr 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

将发布工作流重构为多 Job 的流水线:先统一构建并打包,然后复用打包产物并发发布到 NuGet.org 和 GitHub Packages,最后创建携带合规产物的 GitHub Release,同时收紧权限配置,并将基于标签推导的版本号作为共享输出在各 Job 间传递。

基于标签触发的多 Job 发布流水线时序图

sequenceDiagram
    actor Developer
    participant GitHub
    participant job_build_pack as job_build_pack
    participant job_publish_nuget as job_publish_nuget
    participant job_publish_github as job_publish_github_packages
    participant job_create_release as job_create_release
    participant NuGetOrg
    participant GitHubPackages

    Developer->>GitHub: Push tag
    GitHub->>job_build_pack: Trigger workflow on tag push

    rect rgb(230,230,255)
    job_build_pack->>job_build_pack: Checkout repository at tag
    job_build_pack->>job_build_pack: Setup .NET 10.0.x
    job_build_pack->>job_build_pack: Restore dependencies
    job_build_pack->>job_build_pack: Determine tag version
    job_build_pack->>job_build_pack: dotnet pack with tag-derived version
    job_build_pack->>GitHub: Upload package artifacts (nupkg)
    job_build_pack->>GitHub: Upload compliance artifacts (NOTICE, LICENSE-THIRD-PARTY, SBOM)
    job_build_pack->>GitHub: Expose package_version as job output
    end

    GitHub-->>job_publish_nuget: Start after job_build_pack success
    GitHub-->>job_publish_github: Start after job_build_pack success

    rect rgb(230,255,230)
    job_publish_nuget->>GitHub: Download package artifacts
    job_publish_nuget->>job_publish_nuget: List downloaded packages
    job_publish_nuget->>NuGetOrg: Exchange OIDC for temporary API key
    job_publish_nuget->>NuGetOrg: dotnet nuget push *.nupkg with --skip-duplicate
    end

    rect rgb(255,230,230)
    job_publish_github->>job_publish_github: Setup .NET
    job_publish_github->>GitHub: Download package artifacts
    job_publish_github->>job_publish_github: List downloaded packages
    job_publish_github->>GitHubPackages: Configure GitHub Packages source using GITHUB_TOKEN
    job_publish_github->>GitHubPackages: dotnet nuget push *.nupkg with --skip-duplicate
    end

    GitHub-->>job_create_release: Start after all publish jobs (always)

    rect rgb(255,255,230)
    job_create_release->>GitHub: Download package artifacts
    job_create_release->>GitHub: Download compliance artifacts
    job_create_release->>GitHub: Create GitHub Release using tag and package_version
    job_create_release->>GitHub: Upload nupkg and compliance files as release assets
    end
Loading

发布工作流中 CI Job 及产物复用的流程图

flowchart TD
    subgraph Trigger
        A["Tag push<br/>(any tag)"]
    end

    subgraph Job1["job_build_pack"]
        B1["Checkout repository at tag"]
        B2["Setup .NET 10.0.x"]
        B3["Restore dependencies"]
        B4["Determine tag-derived version<br/>(output: package_version)"]
        B5["dotnet pack → ./packages/*.nupkg"]
        B6["Upload package artifacts<br/>(artifact: packages)"]
        B7["Upload compliance artifacts<br/>(artifact: license-compliance)"]
    end

    subgraph Job2["job_publish_nuget"]
        C1["Download packages artifact"]
        C2["NuGet login via OIDC → temp API key"]
        C3["dotnet nuget push *.nupkg<br/>to NuGet.org with --skip-duplicate"]
    end

    subgraph Job3["job_publish_github_packages"]
        D1["Setup .NET 10.0.x"]
        D2["Download packages artifact"]
        D3["Configure GitHub Packages source<br/>using GITHUB_TOKEN"]
        D4["dotnet nuget push *.nupkg<br/>to GitHub Packages with --skip-duplicate"]
    end

    subgraph Job4["job_create_release"]
        E1["Download packages artifact"]
        E2["Download license-compliance artifact"]
        E3["Create GitHub Release<br/>for tag using package_version"]
        E4["Attach nupkg and compliance files<br/>as release assets"]
    end

    A --> Job1

    B1 --> B2 --> B3 --> B4 --> B5 --> B6 --> B7

    Job1 -->|needs| Job2
    Job1 -->|needs| Job3

    Job2 --> C1 --> C2 --> C3
    Job3 --> D1 --> D2 --> D3 --> D4

    Job2 --> Job4
    Job3 --> Job4

    Job1 -->|output package_version| Job4

    Job4 --> E1 --> E2 --> E3 --> E4
Loading

文件级变更

Change Details Files
将单一的大一统发布 Job 拆分为一个专门的构建/打包 Job,产物可复用且对外暴露共享版本输出。
  • 将该 Job 重命名为 build-pack,并将其权限收紧为仅读取 contents/packages 以及写入 id-token。
  • 从标签中提取版本号,将其存储在带标签的步骤输出中,并作为 Job 级输出 package_version 对外暴露。
  • 新增对生成的 .nupkg 文件的产物上传,以便下游 Job 复用。
  • 保留并稍微清理了许可证/SBOM 合规产物上传以及辅助日志步骤。
.github/workflows/publish.yml
引入一个 NuGet.org 发布 Job,该 Job 消费已构建的产物,并使用基于 OIDC 的临时 API Key 进行发布,支持重复发布保护。
  • 新增依赖于 build-pack 的 publish-nuget Job,权限为只读加 id-token 写入。
  • 在发布前下载包产物并列出文件。
  • 通过 OIDC 登录 NuGet 以获取临时 API Key。
  • 使用 dotnet nuget push 和 --skip-duplicate,将产物目录中的全部 .nupkg 文件推送到 NuGet.org,并对缺失包的情况做了基础错误处理。
.github/workflows/publish.yml
增加使用 GITHUB_TOKEN 支持的 NuGet 源配置来发布到 GitHub Packages 的 Job。
  • 创建依赖于 build-pack 的 publish-github-packages Job,其权限为 contents 读取和 packages 写入。
  • 设置 .NET SDK 并下载共享的包产物。
  • 配置指向仓库所有者 GitHub Packages 源的 github NuGet source,并使用 GITHUB_TOKEN 进行身份验证。
  • 使用 dotnet nuget push 和 --skip-duplicate,将所有 .nupkg 产物推送到 GitHub Packages,并在包缺失时做防护。
.github/workflows/publish.yml
重构 GitHub Release 创建逻辑,使其依赖发布 Job,并使用基于标签推导的版本号,而不是从 .nupkg 元数据中解析。
  • 移除 unzip 安装以及从 .nupkg 的 nuspec 文件中抽取版本号的自定义 Shell 逻辑。
  • 新增 create-release Job,并让其依赖 build-pack、publish-nuget 和 publish-github-packages,其中仅对 build-pack 的成功结果做强依赖。
  • 下载包产物和合规产物,用作 Release 附件。
  • 更新 Release 正文,使其通过 needs.build-pack.outputs.package_version 引用 Package 版本,保留原有的合规章节和附件列表,并继续使用 secrets 中的 GITHUB_TOKEN 进行认证。
.github/workflows/publish.yml

Tips and commands

与 Sourcery 交互

  • 触发新评审: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论即可继续对话。
  • 从评审评论生成 GitHub Issue: 在某条评审评论下回复,请求 Sourcery 从该评论创建 Issue。你也可以直接回复 @sourcery-ai issue 来从该评论创建 Issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai,即可随时生成一个标题。也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 总结: 在 Pull Request 正文中任意位置写上 @sourcery-ai summary,即可在指定位置生成 PR 总结。也可以在 Pull Request 中评论 @sourcery-ai summary 来在任意时间(重新)生成总结。
  • 生成评审者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可在任意时间(重新)生成评审者指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想继续看到它们,这会很实用。
  • 忽略所有 Sourcery 评审: 在 Pull Request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 评审。特别适用于你希望从一次全新的评审开始 —— 别忘了再评论 @sourcery-ai review 来触发新评审!

自定义你的体验

前往你的 dashboard 可以:

  • 启用或禁用评审功能,例如 Sourcery 自动生成的 Pull Request 总结、评审者指南等。
  • 修改评审语言。
  • 添加、删除或编辑自定义评审指令。
  • 调整其他评审相关设置。

获取帮助

Original review guide in English

Reviewer's Guide

Refactors the publish workflow into a multi-job pipeline that builds once, reuses packaged artifacts to publish concurrently to NuGet.org and GitHub Packages, and then creates a GitHub Release with compliance artifacts, while tightening permissions and using the tag-derived version as a shared output.

Sequence diagram for tag-triggered multi-job publish pipeline

sequenceDiagram
    actor Developer
    participant GitHub
    participant job_build_pack as job_build_pack
    participant job_publish_nuget as job_publish_nuget
    participant job_publish_github as job_publish_github_packages
    participant job_create_release as job_create_release
    participant NuGetOrg
    participant GitHubPackages

    Developer->>GitHub: Push tag
    GitHub->>job_build_pack: Trigger workflow on tag push

    rect rgb(230,230,255)
    job_build_pack->>job_build_pack: Checkout repository at tag
    job_build_pack->>job_build_pack: Setup .NET 10.0.x
    job_build_pack->>job_build_pack: Restore dependencies
    job_build_pack->>job_build_pack: Determine tag version
    job_build_pack->>job_build_pack: dotnet pack with tag-derived version
    job_build_pack->>GitHub: Upload package artifacts (nupkg)
    job_build_pack->>GitHub: Upload compliance artifacts (NOTICE, LICENSE-THIRD-PARTY, SBOM)
    job_build_pack->>GitHub: Expose package_version as job output
    end

    GitHub-->>job_publish_nuget: Start after job_build_pack success
    GitHub-->>job_publish_github: Start after job_build_pack success

    rect rgb(230,255,230)
    job_publish_nuget->>GitHub: Download package artifacts
    job_publish_nuget->>job_publish_nuget: List downloaded packages
    job_publish_nuget->>NuGetOrg: Exchange OIDC for temporary API key
    job_publish_nuget->>NuGetOrg: dotnet nuget push *.nupkg with --skip-duplicate
    end

    rect rgb(255,230,230)
    job_publish_github->>job_publish_github: Setup .NET
    job_publish_github->>GitHub: Download package artifacts
    job_publish_github->>job_publish_github: List downloaded packages
    job_publish_github->>GitHubPackages: Configure GitHub Packages source using GITHUB_TOKEN
    job_publish_github->>GitHubPackages: dotnet nuget push *.nupkg with --skip-duplicate
    end

    GitHub-->>job_create_release: Start after all publish jobs (always)

    rect rgb(255,255,230)
    job_create_release->>GitHub: Download package artifacts
    job_create_release->>GitHub: Download compliance artifacts
    job_create_release->>GitHub: Create GitHub Release using tag and package_version
    job_create_release->>GitHub: Upload nupkg and compliance files as release assets
    end
Loading

Flow diagram for CI jobs and artifact reuse in publish workflow

flowchart TD
    subgraph Trigger
        A["Tag push<br/>(any tag)"]
    end

    subgraph Job1["job_build_pack"]
        B1["Checkout repository at tag"]
        B2["Setup .NET 10.0.x"]
        B3["Restore dependencies"]
        B4["Determine tag-derived version<br/>(output: package_version)"]
        B5["dotnet pack → ./packages/*.nupkg"]
        B6["Upload package artifacts<br/>(artifact: packages)"]
        B7["Upload compliance artifacts<br/>(artifact: license-compliance)"]
    end

    subgraph Job2["job_publish_nuget"]
        C1["Download packages artifact"]
        C2["NuGet login via OIDC → temp API key"]
        C3["dotnet nuget push *.nupkg<br/>to NuGet.org with --skip-duplicate"]
    end

    subgraph Job3["job_publish_github_packages"]
        D1["Setup .NET 10.0.x"]
        D2["Download packages artifact"]
        D3["Configure GitHub Packages source<br/>using GITHUB_TOKEN"]
        D4["dotnet nuget push *.nupkg<br/>to GitHub Packages with --skip-duplicate"]
    end

    subgraph Job4["job_create_release"]
        E1["Download packages artifact"]
        E2["Download license-compliance artifact"]
        E3["Create GitHub Release<br/>for tag using package_version"]
        E4["Attach nupkg and compliance files<br/>as release assets"]
    end

    A --> Job1

    B1 --> B2 --> B3 --> B4 --> B5 --> B6 --> B7

    Job1 -->|needs| Job2
    Job1 -->|needs| Job3

    Job2 --> C1 --> C2 --> C3
    Job3 --> D1 --> D2 --> D3 --> D4

    Job2 --> Job4
    Job3 --> Job4

    Job1 -->|output package_version| Job4

    Job4 --> E1 --> E2 --> E3 --> E4
Loading

File-Level Changes

Change Details Files
Split monolithic publish job into a dedicated build/pack job with reusable artifacts and shared version output.
  • Renamed job to build-pack and limited its permissions to read contents/packages and write id-token.
  • Extracted tag version, stored it in a tagged step output, and exposed it as a job-level output package_version.
  • Added artifact upload of generated .nupkg files for reuse by downstream jobs.
  • Kept and slightly cleaned up license/SBOM compliance artifact upload and auxiliary logging steps.
.github/workflows/publish.yml
Introduce a NuGet.org publish job that consumes built artifacts and pushes using OIDC-derived temporary API keys with duplicate protection.
  • Added publish-nuget job depending on build-pack with read-only permissions plus id-token write.
  • Downloaded package artifacts and listed them before publishing.
  • Logged in to NuGet using OIDC to obtain a temporary API key.
  • Pushed all .nupkg files in the artifact directory to NuGet.org using dotnet nuget push with --skip-duplicate and basic error handling for missing packages.
.github/workflows/publish.yml
Add a GitHub Packages publish job using GITHUB_TOKEN-backed NuGet source configuration.
  • Created publish-github-packages job depending on build-pack with contents read and packages write permissions.
  • Set up .NET SDK and downloaded the shared package artifacts.
  • Configured a github NuGet source pointing at the repository owner's GitHub Packages feed using GITHUB_TOKEN for authentication.
  • Pushed all .nupkg artifacts to GitHub Packages with dotnet nuget push and --skip-duplicate, with guard for missing packages.
.github/workflows/publish.yml
Rework GitHub Release creation to depend on publish jobs and use the tag-derived version instead of parsing .nupkg metadata.
  • Removed unzip installation and custom shell logic that extracted version from the .nupkg nuspec file.
  • Added create-release job that depends on build-pack, publish-nuget, and publish-github-packages, but only hard-requires build-pack success.
  • Downloaded both package and compliance artifacts for use as release assets.
  • Updated release body to reference needs.build-pack.outputs.package_version as Package version and kept the compliance section and asset list unchanged, authenticating with GITHUB_TOKEN from secrets.
.github/workflows/publish.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些总体反馈:

  • publish-nuget 这个 job 会调用 dotnet nuget push,但在该 job 中并没有安装 .NET SDK;请在这里添加一个 actions/setup-dotnet 步骤(类似于 build-pack / publish-github-packages),以避免运行时失败。
  • 在 GitHub Packages 配置和 action-gh-release 步骤中,你都引用了 secrets.GITHUB_TOKEN,但内置的 token 实际上是以 github.token 暴露的;请切换为使用 ${{ github.token }}(或者在支持的地方传入 token: ${{ github.token }}),以确保身份验证在无需单独创建 secret 的情况下也能正常工作。
供 AI Agents 使用的提示词
请根据本次代码审查中的评论进行修改:

## 总体评论
- `publish-nuget` 这个 job 会调用 `dotnet nuget push`,但在该 job 中并没有安装 .NET SDK;请在这里添加一个 `actions/setup-dotnet` 步骤(类似于 `build-pack` / `publish-github-packages`),以避免运行时失败。
- 在 GitHub Packages 配置和 `action-gh-release` 步骤中,你都引用了 `secrets.GITHUB_TOKEN`,但内置的 token 实际上是以 `github.token` 暴露的;请切换为使用 `${{ github.token }}`(或者在支持的地方传入 `token: ${{ github.token }}`),以确保身份验证在无需单独创建 secret 的情况下也能正常工作。

## 具体评论

### 评论 1
<location path=".github/workflows/publish.yml" line_range="95-104" />
<code_context>
             sbom-cyclonedx-validation.txt
-      - name: Show packages
+
+  publish-nuget:
+    name: Publish To NuGet.org
+    runs-on: ubuntu-latest
+    needs: build-pack
+
+    permissions:
+      contents: read
+      packages: read
+      id-token: write
+
+    steps:
+      - name: Download package artifacts
+        uses: actions/download-artifact@v5
+        with:
+          name: packages
+          path: ./packages
+
+      - name: Show downloaded packages
         run: ls -la ./packages || true

</code_context>
<issue_to_address>
**issue (bug_risk):** `publish-nuget` 这个 job 在没有设置 .NET SDK 的情况下使用了 `dotnet`,在缺少兼容 SDK 预安装的 runner 上可能会导致失败。

在原先的单一 job 中,.NET 是通过 `actions/setup-dotnet` 设置的,但新的 `publish-nuget` job 在没有该步骤的情况下调用了 `dotnet nuget push`。Ubuntu runner 可能没有安装兼容的 SDK。请在这里添加一个 `Setup .NET` 步骤(参考 `build-pack` / `publish-github-packages`),并使用相同的 `dotnet-version` 以保持行为一致并避免偶发性失败。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据反馈改进后续的代码审查。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The publish-nuget job calls dotnet nuget push but doesn’t install the .NET SDK in that job; add a actions/setup-dotnet step there (similar to build-pack/publish-github-packages) to avoid runtime failures.
  • In both the GitHub Packages configuration and the action-gh-release step you reference secrets.GITHUB_TOKEN, but the built-in token is exposed as github.token; switch to ${{ github.token }} (or pass token: ${{ github.token }} where supported) to ensure authentication works without requiring a separate secret.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `publish-nuget` job calls `dotnet nuget push` but doesn’t install the .NET SDK in that job; add a `actions/setup-dotnet` step there (similar to `build-pack`/`publish-github-packages`) to avoid runtime failures.
- In both the GitHub Packages configuration and the `action-gh-release` step you reference `secrets.GITHUB_TOKEN`, but the built-in token is exposed as `github.token`; switch to `${{ github.token }}` (or pass `token: ${{ github.token }}` where supported) to ensure authentication works without requiring a separate secret.

## Individual Comments

### Comment 1
<location path=".github/workflows/publish.yml" line_range="95-104" />
<code_context>
             sbom-cyclonedx-validation.txt
-      - name: Show packages
+
+  publish-nuget:
+    name: Publish To NuGet.org
+    runs-on: ubuntu-latest
+    needs: build-pack
+
+    permissions:
+      contents: read
+      packages: read
+      id-token: write
+
+    steps:
+      - name: Download package artifacts
+        uses: actions/download-artifact@v5
+        with:
+          name: packages
+          path: ./packages
+
+      - name: Show downloaded packages
         run: ls -la ./packages || true

</code_context>
<issue_to_address>
**issue (bug_risk):** The `publish-nuget` job uses `dotnet` without setting up a .NET SDK, which can lead to failures on runners that don't have a compatible SDK preinstalled.

In the original monolithic job, .NET was set up via `actions/setup-dotnet`, but the new `publish-nuget` job calls `dotnet nuget push` without that step. Ubuntu runners may not have a compatible SDK installed. Please add a `Setup .NET` step here (mirroring `build-pack`/`publish-github-packages`) and use the same `dotnet-version` to keep behavior consistent and avoid flaky failures.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/publish.yml
- 添加 .NET 10.0 环境设置步骤
- 将密码参数从 secrets.GITHUB_TOKEN 替换为 github.token
- 将环境变量中的 secrets.GITHUB_TOKEN 替换为 github.token
@GeWuYou GeWuYou merged commit 152da3f into main Apr 5, 2026
9 checks passed
@GeWuYou GeWuYou deleted the feat/ci-publish-workflow-nuget-github branch April 5, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant