nuget - 修改 github actions pipeline 中 nupkg 的版本

标签 nuget github-actions

我们在 GitHub 上的 NuGet 管道遇到了问题。我们将其设置为运行构建项目的步骤,并使用 NuGet 将其打包为特定版本(RC 版本通常类似于 1.0.0-rc.1),这工作正常,我们可以然后将工件传递到 RC 步骤并使用 NuGet 推送将其上传到需要的位置。

当我们尝试将该软件包从 RC 移动到 GA 时(所需的流程是:构建 > RC > GA),问题就出现了,我们想要采用完全相同的软件包,并且修改版本,使其不再具有 RC 标签(将其剥离为 1.0.0),但是我一直无法找到一种干净的方法来执行此操作。当前的解决方法是采用完全相同的提交并使用 GA 版本重建它,但我们宁愿只修改 RC 版本以获得正确的版本号。

是否有 NuGet 命令或我缺少的东西来完成此任务?我考虑过下载 nupkg 文件,将其安装到输出目录,然后使用正确的版本重新打包它,但我希望可能有更好的方法。

最佳答案

使用操作更新助手的选项很少,

the diff. is helpful depending on what you are publishing, nuget libs you are publishing vs. custom libs - since you did not share your sample yaml/code, I am sharing both.


Option 1: use the Release Tag Updater helper lib. from here or a newer one here from Github or Market Place

对您自己有帮助,即如果您发布 NUGET 库

Update helpers for Github Actions Release configuration Aws Azure pipelines

在 github 操作的 yaml 配置文件中,在要重命名的阶段,您可以使用带有传入值的标记选项

# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: YourProject/YourProject.csproj
          
# NuGet package id, used for version detection & defaults to project name
# PACKAGE_NAME: YourProject

# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.NUGET_API_KEY}}

# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org
          
# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props

# Regex pattern to extract version info in a capturing group
# VERSION_REGEX: <Version>(.*)<\/Version>
          
# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0

# Flag to toggle git tagging, enabled by default
# TAG_COMMIT: true

# Format of the git tag, [*] gets replaced with actual version
# TAG_FORMAT: v*

Option 2: Modify/roll your own yaml properties file

恕我直言,对于您的自定义库,即如果您需要标准yaml属性之外的东西,并且您需要更多。

例如在最后的 release 阶段,使用 yaml 部署部分将其命名为您想要的名称 lib .

   # your previous yaml code ... there should be a section with the below tage configured and it will look for it an update.

conditional update to your local yaml file


主要区别是针对标签名称的主要和次要版本,并且对 Nuget 包很有帮助。

第二个允许您创建超出自定义标签的内容。

关于nuget - 修改 github actions pipeline 中 nupkg 的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67975586/

相关文章:

nuget - 禁止从Nuget.exe输出警告

android - 将来自 github 操作的 Artifact 添加到发布

github-actions - Github 操作 : how to run a workflow created on a non-master branch from the workflow_dispatch event?

aws-cli - GitHub Action -AWS CLI

github - 在 GitHub Actions 中,如何在推送时触发,但前提是 PR 处于事件状态?

c# - 在 Visual Studio 2015 解决方案中恢复所有 Nuget 包

C# Roslyn 编译 - 在动态编译的代码中使用 Nuget 包 - 编译但在运行时抛出异常(无法加载文件或程序集)

github - 如何在 NuGet 上自动发布我的 GitHub 分支?

visual-studio - tfIgnore 在 Visual Studio 2013 中对我不起作用

Github 工作流程 : How to map input option to value