Skip to content

Commit

Permalink
embed app in zip
Browse files Browse the repository at this point in the history
  • Loading branch information
latonz committed Dec 22, 2021
1 parent fb2ab73 commit f757ace
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ apple_id {
sign {
application_identity = "Developer ID Application: Mitchell Hashimoto"
deep = false
keychain = "login.keychain"
}
dmg {
Expand All @@ -176,7 +177,8 @@ zip {
},
"sign" :{
"application_identity" : "Developer ID Application: Mitchell Hashimoto",
"deep": false
"deep": false,
"keychain": "login.keychain"
},
"dmg" :{
"output_path": "terraform.dmg",
Expand Down Expand Up @@ -225,6 +227,8 @@ Supported configurations:
certificate to use to sign applications. This accepts any valid value for the `-s`
flag for the `codesign` binary on macOS. See `man codesign` for detailed
documentation on accepted values.

* `keychain` (`string`) - The name or path of the keychain to lookup the `application_identity`.

* `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
Expand Down
17 changes: 16 additions & 1 deletion package/zip/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,28 @@ func createRoot(ctx context.Context, logger hclog.Logger, opts *Options) (string
if err != nil {
return "", err
}

// further nest the files into another folder with the
// same name as the app.
// This ensures zip files contain the app, rather than the contents
// of the app folder.
// see https://github.com/mitchellh/gon/issues/18
appDir := root
if len(opts.Files) == 1 {
appName := filepath.Base(opts.Files[0])
appDir = filepath.Join(root, appName)
err = os.MkdirAll(appDir, 0777)
if err != nil {
return "", err
}
}

// Setup our args to copy our files into the root
cmd.Args = []string{
filepath.Base(cmd.Path),
}
cmd.Args = append(cmd.Args, opts.Files...)
cmd.Args = append(cmd.Args, root)
cmd.Args = append(cmd.Args, appDir)

// We store all output in out for logging and in case there is an error
var out bytes.Buffer
Expand Down

0 comments on commit f757ace

Please sign in to comment.