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

Commit 024ee78

Browse files
committed
make source/bundle_id optional for notarization-only mode
1 parent d4cbc0c commit 024ee78

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,26 +185,14 @@ Supported configurations:
185185
* `source` (`array<string>`) - A list of files to sign, package, and
186186
notarize. If you want to sign multiple files with different identities
187187
or into different packages, then you should invoke `gon` with separate
188-
configurations.
188+
configurations. This is optional if you're using the notarization-only
189+
mode with the `notarize` block.
189190

190191
* `bundle_id` (`string`) - The [bundle ID](https://cocoacasts.com/what-are-app-ids-and-bundle-identifiers/)
191192
for your application. You should choose something unique for your application.
192193
You can also [register these with Apple](https://developer.apple.com/account/resources/identifiers/list).
193-
194-
* `notarize` (_optional_) - Settings for notarizing an already built files.
195-
This is an alternative to using the `source` option.
196-
197-
* `path` (`string`) - The path to the file to notarize. This must be
198-
one of Apple's supported file types for notarization: dmg, pkg, app, or
199-
zip.
200-
201-
* `bundle_id` (`string`) - The bundle ID to use for this notarization.
202-
This is used instead of the top-level `bundle_id` (which controls the
203-
value for source-based runs).
204-
205-
* `staple` (`bool` _optional_) - Controls if `stapler staple` should run
206-
if notarization succeeds. This should only be set for filetypes that
207-
support it (dmg, pkg, or app).
194+
This is optional if you're using the notarization-only
195+
mode with the `notarize` block.
208196

209197
* `apple_id` - Settings related to the Apple ID to use for notarization.
210198

@@ -248,6 +236,25 @@ Supported configurations:
248236
already exists, it will be overwritten. All files in `source` will be copied
249237
into the root of the zip archive.
250238

239+
Notarization-only mode:
240+
241+
* `notarize` (_optional_) - Settings for notarizing an already built files.
242+
This is an alternative to using the `source` option. This option can be
243+
repeated to notarize multiple files.
244+
245+
* `path` (`string`) - The path to the file to notarize. This must be
246+
one of Apple's supported file types for notarization: dmg, pkg, app, or
247+
zip.
248+
249+
* `bundle_id` (`string`) - The bundle ID to use for this notarization.
250+
This is used instead of the top-level `bundle_id` (which controls the
251+
value for source-based runs).
252+
253+
* `staple` (`bool` _optional_) - Controls if `stapler staple` should run
254+
if notarization succeeds. This should only be set for filetypes that
255+
support it (dmg, pkg, or app).
256+
257+
251258
### Notarization-Only Configuration
252259

253260
You can configure `gon` to notarize already-signed files. This is useful
@@ -267,9 +274,6 @@ those results as well as those in `notarize` blocks.
267274
Example in HCL and then the identical configuration in JSON:
268275

269276
```hcl
270-
sources = []
271-
bundle_id = ""
272-
273277
notarize {
274278
path = "/path/to/terraform.pkg"
275279
bundle_id = "com.mitchellh.example.terraform"
@@ -284,9 +288,6 @@ apple_id {
284288

285289
```json
286290
{
287-
"sources": [],
288-
"bundle_id": "",
289-
290291
"notarize": [{
291292
"path": "/path/to/terraform.pkg",
292293
"bundle_id": "com.mitchellh.example.terraform",

cmd/gon/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ func realMain() int {
8181

8282
// A bunch of validation
8383
if len(cfg.Source) > 0 {
84+
if cfg.BundleId == "" {
85+
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout,
86+
"❗️ `bundle_id` configuration required with `source` set\n")
87+
color.New(color.FgRed).Fprintf(os.Stdout,
88+
"When you set the `source` configuration, you must also specify the\n"+
89+
"`bundle_id` that will be used for packaging and notarization.\n")
90+
return 1
91+
}
92+
8493
if cfg.Sign == nil {
8594
color.New(color.Bold, color.FgRed).Fprintf(os.Stdout,
8695
"❗️ `sign` configuration required with `source` set\n")

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package config
33
// Config is the configuration structure for gon.
44
type Config struct {
55
// Source is the list of binary files to sign.
6-
Source []string `hcl:"source"`
6+
Source []string `hcl:"source,optional"`
77

88
// BundleId is the bundle ID to use for the package that is created.
99
// This should be in a format such as "com.example.app". The value can
1010
// be anything, this is required by Apple.
11-
BundleId string `hcl:"bundle_id"`
11+
BundleId string `hcl:"bundle_id,optional"`
1212

1313
// Notarize is a single file (usually a .pkg installer or zip)
1414
// that is ready for notarization as-is

0 commit comments

Comments
 (0)