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

问题描述

我正在尝试使用 goreleaser 签署我的 golang - 并最终使用 Homebrew 进行分发。但这需要使用 Apple Developer ID 进行签名才能分发给 MacO。

您是否在使用 gon 时看到以下错误并已修复?

来自 here 的 yaml 示例

# 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't use go modules.
    - go mod tidy
    # you may remove this if you don'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 文件

# The path follows a pattern
# ./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]
      • ==> ✏️  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

解决方法

你的配置应该是这样的:

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: "${artifact}.dmg"
    ids:
    - foo-macos
    cmd: gon
    args:
    - gon.hcl
    artifacts: all

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

Gon's repository 中的更多信息。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...