Skip to content

Commit

Permalink
add keychain option
Browse files Browse the repository at this point in the history
  • Loading branch information
latonz committed Dec 22, 2021
1 parent 1569d9b commit fb2ab73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/gon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func realMain() int {
err = sign.Sign(context.Background(), &sign.Options{
Files: cfg.Source,
Identity: cfg.Sign.ApplicationIdentity,
Keychain: cfg.Sign.Keychain,
Entitlements: cfg.Sign.EntitlementsFile,
Deep: cfg.Sign.Deep,
Logger: logger.Named("sign"),
Expand Down Expand Up @@ -233,6 +234,7 @@ func realMain() int {
err = sign.Sign(context.Background(), &sign.Options{
Files: []string{cfg.Dmg.OutputPath},
Identity: cfg.Sign.ApplicationIdentity,
Keychain: cfg.Sign.Keychain,
Deep: cfg.Sign.Deep,
Logger: logger.Named("dmg"),
})
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type Sign struct {
// ApplicationIdentity is the ID or name of the certificate to
// use for signing binaries. This is used for all binaries in "source".
ApplicationIdentity string `hcl:"application_identity"`
// Specify a path or a name of the keychain to use.
Keychain string `hcl:"keychain,optional"`
// Specify a path to an entitlements file in plist format
EntitlementsFile string `hcl:"entitlements_file,optional"`
// Specific to request a --deep codesigning.
Expand Down
7 changes: 7 additions & 0 deletions sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type Options struct {
// be in a variety of forms.
Identity string

// Keychain is an (optional) path or name of a keychain to use.
Keychain string

// Entitlements is an (optional) path to a plist format .entitlements file
Entitlements string

Expand Down Expand Up @@ -84,6 +87,10 @@ func Sign(ctx context.Context, opts *Options) error {
cmd.Args = append(cmd.Args, "--deep")
}

if opts.Keychain != "" {
cmd.Args = append(cmd.Args, "--keychain", opts.Keychain)
}

// Append the files that we want to sign
cmd.Args = append(cmd.Args, opts.Files...)

Expand Down

0 comments on commit fb2ab73

Please sign in to comment.