@@ -81,83 +81,123 @@ func realMain() int {
8181
8282 // Notarize is an alternative to "Source", where you specify
8383 // a single .pkg or .zip that is ready for notarization and stapling
84- if cfg .Notarize != nil {
85- items = append (items , & item {Path : cfg .Notarize .Package , Staple : cfg .Notarize .Staple })
84+ if len (cfg .Notarize ) > 0 {
85+ for _ , c := range cfg .Notarize {
86+ items = append (items , & item {
87+ Path : c .Path ,
88+ BundleId : c .BundleId ,
89+ Staple : c .Staple ,
90+ })
91+ }
92+ }
93+
94+ if len (cfg .Source ) > 0 {
95+ if cfg .Sign == nil {
96+ color .New (color .Bold , color .FgRed ).Fprintf (os .Stdout ,
97+ "❗️ `sign` configuration required with `source` set\n " )
98+ color .New (color .FgRed ).Fprintf (os .Stdout ,
99+ "When you set the `source` configuration, you must also specify the\n " +
100+ "`sign` configuration to sign the input files.\n " )
101+ return 1
102+ }
103+ } else {
104+ if cfg .Zip != nil {
105+ color .New (color .Bold , color .FgRed ).Fprintf (os .Stdout ,
106+ "❗️ `zip` can only be set while `source` is also set\n " )
107+ color .New (color .FgRed ).Fprintf (os .Stdout ,
108+ "Zip packaging is only supported when `source` is specified. This is\n " +
109+ "because the `zip` option packages the source files. If there are no\n " +
110+ "source files specified, then there is nothing to package.\n " )
111+ return 1
112+ }
113+
114+ if cfg .Dmg != nil {
115+ color .New (color .Bold , color .FgRed ).Fprintf (os .Stdout ,
116+ "❗️ `dmg` can only be set while `source` is also set\n " )
117+ color .New (color .FgRed ).Fprintf (os .Stdout ,
118+ "Dmg packaging is only supported when `source` is specified. This is\n " +
119+ "because the `dmg` option packages the source files. If there are no\n " +
120+ "source files specified, then there is nothing to package.\n " )
121+ return 1
122+ }
86123 }
87124
88125 // If we have no items to sign then its probably an error
89- if len (cfg .Source ) == 0 && cfg .Notarize == nil {
126+ if len (cfg .Source ) == 0 && len ( cfg .Notarize ) == 0 {
90127 color .New (color .Bold , color .FgRed ).Fprintf (os .Stdout , "❗️ No source files specified\n " )
91128 color .New (color .FgRed ).Fprintf (os .Stdout ,
92129 "Your configuration had an empty 'source' and empty 'notarize' values. This must be populated with\n " +
93130 "at least one file to sign, package, and notarize.\n " )
94131 return 1
95132 }
96133
97- if len (cfg .Source ) > 0 && cfg .Sign != nil {
98- // Perform codesigning
99- color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Signing files...\n " , iconSign )
100- err = sign .Sign (context .Background (), & sign.Options {
101- Files : cfg .Source ,
102- Identity : cfg .Sign .ApplicationIdentity ,
103- Logger : logger .Named ("sign" ),
104- })
105- if err != nil {
106- fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error signing files:\n \n %s\n " , err ))
107- return 1
134+ // If we're in source mode, then sign & package as configured
135+ if len (cfg .Source ) > 0 {
136+ if cfg .Sign != nil {
137+ // Perform codesigning
138+ color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Signing files...\n " , iconSign )
139+ err = sign .Sign (context .Background (), & sign.Options {
140+ Files : cfg .Source ,
141+ Identity : cfg .Sign .ApplicationIdentity ,
142+ Logger : logger .Named ("sign" ),
143+ })
144+ if err != nil {
145+ fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error signing files:\n \n %s\n " , err ))
146+ return 1
147+ }
148+ color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Code signing successful\n " )
108149 }
109- color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Code signing successful\n " )
110- }
111150
112- // Create a zip
113- if len (cfg .Source ) > 0 && cfg .Zip != nil {
114- color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Creating Zip archive...\n " , iconPackage )
115- err = zip .Zip (context .Background (), & zip.Options {
116- Files : cfg .Source ,
117- OutputPath : cfg .Zip .OutputPath ,
118- })
119- if err != nil {
120- fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error creating zip archive:\n \n %s\n " , err ))
121- return 1
151+ // Create a zip
152+ if cfg .Zip != nil {
153+ color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Creating Zip archive...\n " , iconPackage )
154+ err = zip .Zip (context .Background (), & zip.Options {
155+ Files : cfg .Source ,
156+ OutputPath : cfg .Zip .OutputPath ,
157+ })
158+ if err != nil {
159+ fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error creating zip archive:\n \n %s\n " , err ))
160+ return 1
161+ }
162+ color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Zip archive created with signed files\n " )
163+
164+ // Queue to notarize
165+ items = append (items , & item {Path : cfg .Zip .OutputPath })
122166 }
123- color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Zip archive created with signed files\n " )
124167
125- // Queue to notarize
126- items = append (items , & item {Path : cfg .Zip .OutputPath })
127- }
168+ // Create a dmg
169+ if cfg .Dmg != nil && cfg .Sign != nil {
170+ // First create the dmg itself. This passes in the signed files.
171+ color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Creating dmg...\n " , iconPackage )
172+ color .New ().Fprintf (os .Stdout , " This will open Finder windows momentarily.\n " )
173+ err = dmg .Dmg (context .Background (), & dmg.Options {
174+ Files : cfg .Source ,
175+ OutputPath : cfg .Dmg .OutputPath ,
176+ VolumeName : cfg .Dmg .VolumeName ,
177+ Logger : logger .Named ("dmg" ),
178+ })
179+ if err != nil {
180+ fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error creating dmg:\n \n %s\n " , err ))
181+ return 1
182+ }
183+ color .New ().Fprintf (os .Stdout , " Dmg file created: %s\n " , cfg .Dmg .OutputPath )
184+
185+ // Next we need to sign the actual DMG as well
186+ color .New ().Fprintf (os .Stdout , " Signing dmg...\n " )
187+ err = sign .Sign (context .Background (), & sign.Options {
188+ Files : []string {cfg .Dmg .OutputPath },
189+ Identity : cfg .Sign .ApplicationIdentity ,
190+ Logger : logger .Named ("dmg" ),
191+ })
192+ if err != nil {
193+ fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error signing dmg:\n \n %s\n " , err ))
194+ return 1
195+ }
196+ color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Dmg created and signed\n " )
128197
129- // Create a dmg
130- if len (cfg .Source ) > 0 && cfg .Dmg != nil && cfg .Sign != nil {
131- // First create the dmg itself. This passes in the signed files.
132- color .New (color .Bold ).Fprintf (os .Stdout , "==> %s Creating dmg...\n " , iconPackage )
133- color .New ().Fprintf (os .Stdout , " This will open Finder windows momentarily.\n " )
134- err = dmg .Dmg (context .Background (), & dmg.Options {
135- Files : cfg .Source ,
136- OutputPath : cfg .Dmg .OutputPath ,
137- VolumeName : cfg .Dmg .VolumeName ,
138- Logger : logger .Named ("dmg" ),
139- })
140- if err != nil {
141- fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error creating dmg:\n \n %s\n " , err ))
142- return 1
143- }
144- color .New ().Fprintf (os .Stdout , " Dmg file created: %s\n " , cfg .Dmg .OutputPath )
145-
146- // Next we need to sign the actual DMG as well
147- color .New ().Fprintf (os .Stdout , " Signing dmg...\n " )
148- err = sign .Sign (context .Background (), & sign.Options {
149- Files : []string {cfg .Dmg .OutputPath },
150- Identity : cfg .Sign .ApplicationIdentity ,
151- Logger : logger .Named ("dmg" ),
152- })
153- if err != nil {
154- fmt .Fprintf (os .Stdout , color .RedString ("❗️ Error signing dmg:\n \n %s\n " , err ))
155- return 1
198+ // Queue to notarize
199+ items = append (items , & item {Path : cfg .Dmg .OutputPath , Staple : true })
156200 }
157- color .New (color .Bold , color .FgGreen ).Fprintf (os .Stdout , " Dmg created and signed\n " )
158-
159- // Queue to notarize
160- items = append (items , & item {Path : cfg .Dmg .OutputPath , Staple : true })
161201 }
162202
163203 // If we have no items to notarize then its probably an error in the configuration.
0 commit comments