Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Implements #30, a way to pass --deep flag to codesign tool #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ apple_id {

sign {
application_identity = "Developer ID Application: Mitchell Hashimoto"
deep = false
}

dmg {
Expand All @@ -174,7 +175,8 @@ zip {
"password": "@env:AC_PASSWORD"
},
"sign" :{
"application_identity" : "Developer ID Application: Mitchell Hashimoto"
"application_identity" : "Developer ID Application: Mitchell Hashimoto",
"deep": false
},
"dmg" :{
"output_path": "terraform.dmg",
Expand Down Expand Up @@ -224,6 +226,10 @@ Supported configurations:
flag for the `codesign` binary on macOS. See `man codesign` for detailed
documentation on accepted values.

* `deep` (`bool` _optional_) - If true, the `--deep` flag is used, which will recursively
codesign any directory paths (such as an *.app directory, for example.) Has no effect on
individual file paths.

* `entitlements_file` (`string` _optional_) - The full path to a plist format .entitlements file, used for the `--entitlements` argument to `codesign`

* `dmg` (_optional_) - Settings related to creating a disk image (dmg) as output.
Expand Down
2 changes: 2 additions & 0 deletions cmd/gon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func realMain() int {
Files: cfg.Source,
Identity: cfg.Sign.ApplicationIdentity,
Entitlements: cfg.Sign.EntitlementsFile,
Deep: cfg.Sign.Deep,
Logger: logger.Named("sign"),
})
if err != nil {
Expand Down Expand Up @@ -232,6 +233,7 @@ func realMain() int {
err = sign.Sign(context.Background(), &sign.Options{
Files: []string{cfg.Dmg.OutputPath},
Identity: cfg.Sign.ApplicationIdentity,
Deep: cfg.Sign.Deep,
Logger: logger.Named("dmg"),
})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type Sign struct {
ApplicationIdentity string `hcl:"application_identity"`
// Specify a path to an entitlements file in plist format
EntitlementsFile string `hcl:"entitlements_file,optional"`
// Specific to request a --deep codesigning.
Deep bool `hcl:"deep,optional"`
}

// Dmg are the options for a dmg file as output.
Expand Down
8 changes: 8 additions & 0 deletions sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type Options struct {
// Entitlements is an (optional) path to a plist format .entitlements file
Entitlements string

// Deep is an (optional) toggle to force the --deep flag when codesigning.
// This can be useful for signing *.app directories and their child files.
Deep bool

// Output is an io.Writer where the output of the command will be written.
// If this is nil then the output will only be sent to the log (if set)
// or in the error result value if signing failed.
Expand Down Expand Up @@ -76,6 +80,10 @@ func Sign(ctx context.Context, opts *Options) error {
cmd.Args = append(cmd.Args, "--entitlements", opts.Entitlements)
}

if opts.Deep {
cmd.Args = append(cmd.Args, "--deep")
}

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

Expand Down