0

在成功构建 go 二进制文件 (cli) 后,我想将二进制文件发布到存储库管理器,例如 Artifactory。我发现了各种关于上传 jar 依赖项的参考,但没有特定于rules_go

谁能指出我正确的方向?

4

2 回答 2

0

感谢您的跟进。我一直在挖掘并没有找到解决方案,但提出了以下问题。

def _local_deploy_impl(ctx):
    target = ctx.attr.target
    shell_commands = ""

    for s in ctx.files.srcs:
        shell_commands += "sudo cp %s %s\n" % (s.short_path, target) # <2>

    ctx.actions.write(
        output = ctx.outputs.executable,
        is_executable = True,
        content = shell_commands,
    )
    runfiles = ctx.runfiles(files = ctx.files.srcs)
    return DefaultInfo(
        executable = ctx.outputs.executable,
        runfiles = runfiles,
    )

local_deploy = rule(
    executable = True,
    implementation = _local_deploy_impl,
    attrs = {
        "srcs": attr.label_list(allow_files = True),
        "target": attr.string(default = "/usr/local/bin", doc = "Deployment target directory"),
    },
)

在构建文件中包含:

local_deploy(
    name = "install",
    srcs = [":binary"],
)

srcs 引用将在本地安装的另一个规则的二进制输出。

有什么改进的建议吗?

于 2021-01-02T20:13:03.890 回答
0

I don't think there is a publish story for go. It took 4 years to implement #1372, it's probably easier to leave the publish part out of the Bazel whose mission is to build.

于 2020-12-28T12:15:48.300 回答