goreleaser使用gon进行签名-捆绑格式无法识别、无效或不适用。

huangapple go评论78阅读模式
英文:

goreleaser signing using gon - bundle format unrecognized, invalid, or unsuitable

问题

我正在尝试使用goreleaser对我的golang代码进行签名,并最终使用Homebrew进行分发。但这将需要使用Apple Developer ID进行签名,以便能够分发到MacOS。

你是否遇到了使用gon并解决了以下错误?

来自此处的yaml示例(https://goreleaser.com/customization/sign/#executables)

# 这是一个带有一些合理默认值的示例.goreleaser.yml文件。
# 确保查看http://goreleaser.com上的文档
before:
  hooks:
    # 如果您不使用go模块,可以删除此项。
    - go mod tidy
    # 如果您不需要go generate,可以删除此项。
    - go generate ./...

builds:
- binary: foo
  id: foo
  goos:
  - linux
  goarch:
  - amd64
# 注意,我们仅需要一个单独的构建用于MacOS二进制文件:
- binary: foo
  id: appbrew-macos
  goos:
  - darwin
  goarch:
  - amd64
  hooks:
    post: gon gon.hcl

gon.hcl文件

# 路径遵循以下模式
# ./dist/BUILD-ID_TARGET/BINARY-NAME

source = ["."]
bundle_id = "com.mydomain.mybrew"

apple_id {
    username = "<my_developer_id@application.com>"
    password = "@keychain:developer_id_application"
}

sign {
  application_identity = "Developer ID Application: my name (452534542)"
}

我可以验证密码是否已被检索出来:

security find-generic-password -w -s 'developer_id_application' -a '<my_developer_id@application.com>'

错误:

• archives         
  • creating                  archive=dist/appbrew_0.1.19_Darwin_x86_64.tar.gz
  • creating                  archive=dist/appbrew_0.1.19_Darwin_arm64.tar.gz
  • creating                  archive=dist/appbrew_0.1.19_Linux_i386.tar.gz
  • creating                  archive=dist/appbrew_0.1.19_Linux_x86_64.tar.gz
  • creating                  archive=dist/appbrew_0.1.19_Linux_arm64.tar.gz
• creating source archive
• linux packages   
• snapcraft packages
• calculating checksums
  • checksumming              file=appbrew_0.1.19_Linux_arm64.tar.gz
  • checksumming              file=appbrew_0.1.19_Darwin_arm64.tar.gz
  • checksumming              file=appbrew_0.1.19_Linux_x86_64.tar.gz
  • checksumming              file=appbrew_0.1.19_Darwin_x86_64.tar.gz
  • checksumming              file=appbrew_0.1.19_Linux_i386.tar.gz
• signing artifacts
  • signing                   cmd=[gon gon.hcl]
  • ==&gt; ✏️  Signing files...
cmd=gon
  • ❗️ Error signing files:

error signing:

.: bundle format unrecognized, invalid, or unsuitable

cmd=gon
⨯ release failed after 3.49s error=sign: gon failed
英文:

I am trying to sign my golang using goreleaser - and eventually distribute using Homebrew. But this will require signing with Apple Developer ID to be able to distribute to MacOs.

Have you seen the following error using gon and fixed it?

yaml sample from here

# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
  hooks:
    # You may remove this if you don&#39;t use go modules.
    - go mod tidy
    # you may remove this if you don&#39;t need go generate
    - go generate ./...

builds:
- binary: foo
  id: foo
  goos:
  - linux
  goarch:
  - amd64
# notice that we need a separated build for the MacOS binary only:
- binary: foo
  id: appbrew-macos
  goos:
  - darwin
  goarch:
  - amd64
  hooks:
    post: gon gon.hcl

gon.hcl file

# The path follows a pattern
# ./dist/BUILD-ID_TARGET/BINARY-NAME

source = [&quot;.&quot;]
bundle_id = &quot;com.mydomain.mybrew&quot;

apple_id {
    username = &quot;&lt;my_developer_id@application.com&gt;&quot;
    password = &quot;@keychain:developer_id_application&quot;
}

sign {
  application_identity = &quot;Developer ID Application: my name (452534542)&quot;
}

I can verify that the password is retrieve using:

security find-generic-password -w -s &#39;developer_id_application&#39; -a &#39;&lt;my_developer_id@application.com&gt;&#39;

Error:

   • archives         
      • creating                  archive=dist/appbrew_0.1.19_Darwin_x86_64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Darwin_arm64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_i386.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_x86_64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_arm64.tar.gz
   • creating source archive
   • linux packages   
   • snapcraft packages
   • calculating checksums
      • checksumming              file=appbrew_0.1.19_Linux_arm64.tar.gz
      • checksumming              file=appbrew_0.1.19_Darwin_arm64.tar.gz
      • checksumming              file=appbrew_0.1.19_Linux_x86_64.tar.gz
      • checksumming              file=appbrew_0.1.19_Darwin_x86_64.tar.gz
      • checksumming              file=appbrew_0.1.19_Linux_i386.tar.gz
   • signing artifacts
      • signing                   cmd=[gon gon.hcl]
      • ==&gt; ✏️  Signing files...
 cmd=gon
      • ❗️ Error signing files:

error signing:

.: bundle format unrecognized, invalid, or unsuitable

 cmd=gon
   ⨯ release failed after 3.49s error=sign: gon failed

答案1

得分: 1

你的配置应该是这样的:

builds:
- binary: foo
  id: foo
  goos:
  - linux
  - windows
  goarch:
  - amd64
# 仅用于macos的独立构建
- binary: foo
  id: foo-macos
  goos:
  - darwin
  goarch:
  - amd64
signs:
  - signature: "${artifact}.dmg"
    ids:
    - foo-macos
    cmd: gon
    args:
    - gon.hcl
    artifacts: all

请注意,签名是在signs步骤中完成的,而不是在你的配置中的builds步骤中。

更多信息请参考Gon的存储库

英文:

Your config should probably be something like:

builds:
- binary: foo
  id: foo
  goos:
  - linux
  - windows
  goarch:
  - amd64
# separated build for macos only
- binary: foo
  id: foo-macos
  goos:
  - darwin
  goarch:
  - amd64
signs:
  - signature: &quot;${artifact}.dmg&quot;
    ids:
    - foo-macos
    cmd: gon
    args:
    - gon.hcl
    artifacts: all

notice that signing is done in the signs step, not in the builds like in your config.

More info in Gon's repository.

huangapple
  • 本文由 发表于 2021年7月16日 00:42:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/68397720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定