【问题标题】:Modifying the version of a nupkg in github actions pipeline在 github 操作管道中修改 nupkg 的版本
【发布时间】:2021-06-14 18:41:33
【问题描述】:

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

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

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

【问题讨论】:

  • 请发布您的配置文件或示例代码,以及错误/问题

标签: nuget github-actions


【解决方案1】:

使用Action Update Helpers 的选项很少,

差异。是否有帮助取决于您发布的内容,nuget libs 您发布的内容与 自定义库 - 因为您没有分享您的示例 yaml/代码,所以我将两者都分享。


Option 1:使用 Release Tag Updater 辅助库。来自here 或更新的here from GithubMarket Place

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

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

# 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: 修改/滚动你自己的 yaml properties 文件

恕我直言,您的自定义库,即如果您需要超出标准 yaml properties 的内容,并且需要更多内容。

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

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


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

第二个允许您创建超越和自定义标签的东西。

【讨论】:

    猜你喜欢
    • 2021-12-22
    • 1970-01-01
    • 1970-01-01
    • 2020-04-09
    • 2021-03-01
    • 1970-01-01
    • 2021-06-29
    • 1970-01-01
    • 2020-04-04
    相关资源
    最近更新 更多