Skip to content

Commit 737a1f7

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 073b345 + 2d4f161 commit 737a1f7

22 files changed

+455
-538
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cmd/gon/gon
12
dist/
23

34
# For testing:

.gon.hcl

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
source = ["./dist/gon"]
1+
source = ["./dist/macos_darwin_amd64/gon"]
22
bundle_id = "com.mitchellh.gon"
33

44
apple_id {
55
username = "[email protected]"
66
password = "@env:AC_PASSWORD"
7+
provider = "UL304B4VGY"
78
}
89

910
sign {
1011
application_identity = "97E4A93EAA8BAC7A8FD2383BFA459D2898100E56"
1112
}
1213

1314
zip {
14-
output_path = "./dist/gon.zip"
15+
output_path = "./dist/gon_macos.zip"
1516
}
1617

1718
dmg {
18-
output_path = "./dist/gon.dmg"
19+
output_path = "./dist/gon_macos.dmg"
1920
volume_name = "gon"
2021
}

.goreleaser.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
env:
2+
- GO111MODULE=on
3+
4+
before:
5+
hooks:
6+
- go mod download
7+
8+
builds:
9+
- id: macos
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- darwin
14+
goarch:
15+
- amd64
16+
dir: ./cmd/gon/
17+
18+
archives:
19+
- id: macos-zip
20+
format: zip
21+
name_template: "{{ .ProjectName }}_{{ .Os }}"
22+
replacements:
23+
darwin: macos
24+
amd64: x86_64
25+
26+
checksum:
27+
disable: true
28+
29+
signs:
30+
- signature: "${artifact}_macos.dmg"
31+
ids:
32+
- macos-zip
33+
cmd: gon
34+
args:
35+
- .gon.hcl
36+
artifacts: all
37+
38+
snapshot:
39+
name_template: "{{ .Tag }}-next"
40+
41+
changelog:
42+
sort: asc
43+
filters:
44+
exclude:
45+
- 'README'
46+
47+
release:
48+
ids:
49+
- none
50+
extra_files:
51+
- glob: ./dist/gon_macos.dmg
52+
- glob: ./dist/gon_macos.zip
53+
54+
brews:
55+
- tap:
56+
owner: mitchellh
57+
name: homebrew-gon
58+
description: "Sign, notarize, and package macOS CLI applications written in any language."

Makefile

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
VERSION := 0.2.2
2-
3-
# Note that I'd love to use goreleaser for this but they don't quite
4-
# have the hooks yet to be able to merge in gon support. Ideally they'd
5-
# just integrate natively in some way.
6-
build: clean
7-
mkdir -p dist
8-
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o ./dist/gon ./cmd/gon
9-
.PHONY: build
10-
11-
# release will package the distribution packages, sign, and notarize
12-
release: build
13-
./dist/gon .gon.hcl
1+
# release will package the distribution packages, sign, and notarize. It
2+
# will then upload the release to GitHub and publish the Homebrew tap.
3+
#
4+
# AFTER THIS YOU MUST MANUALLY DELETE the checksums.txt file since it is
5+
# incomplete and we don't need checksums since our artifacts are signed.
6+
release:
7+
goreleaser --rm-dist
148
.PHONY: release
159

1610
clean:

README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
**Archived:** I unfortunately no longer make active use of this project
2+
and haven't properly maintained it since early 2022. I welcome anyone to
3+
fork and take over this project.
4+
5+
-----------------------------------------------------
6+
17
# gon - CLI and Go Library for macOS Notarization
28

39
gon is a simple, no-frills tool for
@@ -33,6 +39,7 @@ gon helps you automate the process of notarization.
3339
- [Prompts](#prompts)
3440
- [Usage with GoReleaser](#usage-with-goreleaser)
3541
- [Go Library](#go-library)
42+
- [Troubleshooting](#troubleshooting)
3643
- [Roadmap](#roadmap)
3744

3845
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -57,7 +64,11 @@ The example below runs `gon` against itself to generate a zip and dmg.
5764

5865
## Installation
5966

60-
To install `gon`, download the appropriate release for your platform
67+
The easiest way to install `gon` is via [Homebrew](https://brew.sh):
68+
69+
$ brew install mitchellh/gon/gon
70+
71+
You may also download the appropriate release for your platform
6172
from the [releases page](https://github.com/mitchellh/gon/releases).
6273
These are all signed and notarized to run out of the box on macOS 10.15+.
6374

@@ -144,6 +155,7 @@ bundle_id = "com.mitchellh.example.terraform"
144155
apple_id {
145156
username = "[email protected]"
146157
password = "@env:AC_PASSWORD"
158+
provider = "UL304B4VGY"
147159
}
148160
149161
sign {
@@ -166,7 +178,8 @@ zip {
166178
"bundle_id" : "com.mitchellh.example.terraform",
167179
"apple_id": {
168180
"username" : "[email protected]",
169-
"password": "@env:AC_PASSWORD"
181+
"password": "@env:AC_PASSWORD",
182+
"provider": "UL304B4VGY"
170183
},
171184
"sign" :{
172185
"application_identity" : "Developer ID Application: Mitchell Hashimoto"
@@ -208,11 +221,14 @@ Supported configurations:
208221
variable. If this value isn't set, we'll attempt to use the `AC_PASSWORD`
209222
environment variable as a default.
210223

224+
**NOTE**: If you have 2FA enabled, the password must be an application password, not
225+
your normal apple id password. See [Troubleshooting](#troubleshooting) for details.
226+
211227
* `api_key` (`string` _optional_) - The API key required for JWT authentication while using validation, upload, and notarization. This option will search the following directories in sequence for a private key file with the name of 'AuthKey_<api_key>.p8': './private_keys', '~/private_keys', '~/.private_keys' and '~/.appstoreconnect/private_keys'. API key can be used instead of providing username and password.
212228

213229
* `api_issuer` (`string` _optional_ ) - The Issuer ID. Required if --api_key is specified.
214230

215-
* `provider` (`string` _optional_) - The App Store Connect provider when using
231+
* `provider` (`string`) - The App Store Connect provider when using
216232
multiple teams within App Store Connect. If this isn't set, we'll attempt
217233
to read the `AC_PROVIDER` environment variable as a default.
218234

@@ -420,6 +436,12 @@ package, notarization, and stapling steps. This lets you integrate this
420436
functionality into any tooling easily vs. having an opinionated `gon`-CLI
421437
experience.
422438

439+
## Troubleshooting
440+
441+
### "We are unable to create an authentication session. (-22016)"
442+
443+
You likely have Apple 2FA enabled. You'll need to [generate an application password](https://appleid.apple.com/account/manage) and use that instead of your Apple ID password.
444+
423445
## Roadmap
424446

425447
These are some things I'd love to see but aren't currently implemented.

cmd/gon/item.go

+11-81
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package main
22

33
import (
44
"context"
5-
"fmt"
65
"os"
76
"sync"
87

98
"github.com/fatih/color"
109
"github.com/hashicorp/go-hclog"
11-
"github.com/hashicorp/go-multierror"
1210

1311
"github.com/mitchellh/gon/internal/config"
1412
"github.com/mitchellh/gon/notarize"
@@ -66,21 +64,20 @@ func (i *item) notarize(ctx context.Context, opts *processOptions) error {
6664
}
6765

6866
// Start notarization
69-
info, err := notarize.Notarize(ctx, &notarize.Options{
70-
File: i.Path,
71-
BundleId: bundleId,
72-
Username: opts.Config.AppleId.Username,
73-
Password: opts.Config.AppleId.Password,
74-
APIKey: opts.Config.AppleId.APIKey,
75-
APIIssuer: opts.Config.AppleId.APIIssuer,
76-
Provider: opts.Config.AppleId.Provider,
77-
Logger: opts.Logger.Named("notarize"),
78-
Status: &statusHuman{Prefix: opts.Prefix, Lock: lock},
79-
UploadLock: opts.UploadLock,
67+
_, _, err := notarize.Notarize(ctx, &notarize.Options{
68+
File: i.Path,
69+
DeveloperId: opts.Config.AppleId.Username,
70+
Password: opts.Config.AppleId.Password,
71+
APIKey: opts.Config.AppleId.APIKey,
72+
APIIssuer: opts.Config.AppleId.APIIssuer,
73+
Provider: opts.Config.AppleId.Provider,
74+
Logger: opts.Logger.Named("notarize"),
75+
Status: &statusHuman{Prefix: opts.Prefix, Lock: lock},
76+
UploadLock: opts.UploadLock,
8077
})
8178

8279
// Save the error state. We don't save the notarization result yet
83-
// because we don't know it for sure until we download the log file.
80+
// because we don't know it for sure until we retrieve the log information.
8481
i.State.NotarizeError = err
8582

8683
// If we had an error, we mention immediate we have an error.
@@ -90,73 +87,6 @@ func (i *item) notarize(ctx context.Context, opts *processOptions) error {
9087
lock.Unlock()
9188
}
9289

93-
// If we have a log file, download it. We do this whether we have an error
94-
// or not because the log file can contain more details about the error.
95-
if info != nil && info.LogFileURL != "" {
96-
opts.Logger.Info(
97-
"downloading log file for notarization",
98-
"request_uuid", info.RequestUUID,
99-
"url", info.LogFileURL,
100-
)
101-
102-
log, logerr := notarize.DownloadLog(info.LogFileURL)
103-
opts.Logger.Debug("log file downloaded", "log", log, "err", logerr)
104-
if logerr != nil {
105-
opts.Logger.Warn(
106-
"error downloading log file, this isn't a fatal error",
107-
"err", err,
108-
)
109-
110-
// If we already failed notarization, just return that error
111-
if err := i.State.NotarizeError; err != nil {
112-
return err
113-
}
114-
115-
// If it appears we succeeded notification, we make a new error.
116-
// We can't say notarization is successful without downloading this
117-
// file because warnings will cause notarization to not work
118-
// when loaded.
119-
lock.Lock()
120-
color.New(color.FgRed).Fprintf(os.Stdout,
121-
" %sError downloading log file to verify notarization.\n",
122-
opts.Prefix,
123-
)
124-
lock.Unlock()
125-
126-
return fmt.Errorf(
127-
"Error downloading log file to verify notarization success: %s\n\n"+
128-
"You can download the log file manually at: %s",
129-
logerr, info.LogFileURL,
130-
)
131-
}
132-
133-
// If we have any issues then it is a failed notarization. Notarization
134-
// can "succeed" with warnings, but when you attempt to use/open a file
135-
// Gatekeeper rejects it. So we currently reject any and all issues.
136-
if len(log.Issues) > 0 {
137-
var err error
138-
139-
lock.Lock()
140-
color.New(color.FgRed).Fprintf(os.Stdout,
141-
" %s%d issues during notarization:\n",
142-
opts.Prefix, len(log.Issues))
143-
for idx, issue := range log.Issues {
144-
color.New(color.FgRed).Fprintf(os.Stdout,
145-
" %sIssue #%d (%s) for path %q: %s\n",
146-
opts.Prefix, idx+1, issue.Severity, issue.Path, issue.Message)
147-
148-
// Append the error so we can return it
149-
err = multierror.Append(err, fmt.Errorf(
150-
"%s for path %q: %s",
151-
issue.Severity, issue.Path, issue.Message,
152-
))
153-
}
154-
lock.Unlock()
155-
156-
return err
157-
}
158-
}
159-
16090
// If we aren't notarized, then return
16191
if err := i.State.NotarizeError; err != nil {
16292
return err

cmd/gon/status_human.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ type statusHuman struct {
1818
Prefix string
1919
Lock *sync.Mutex
2020

21-
lastStatus string
21+
lastInfoStatus string
22+
lastLogStatus string
2223
}
2324

2425
func (s *statusHuman) Submitting() {
@@ -37,13 +38,23 @@ func (s *statusHuman) Submitted(uuid string) {
3738
os.Stdout, " %sWaiting for results from Apple. This can take minutes to hours.\n", s.Prefix)
3839
}
3940

40-
func (s *statusHuman) Status(info notarize.Info) {
41+
func (s *statusHuman) InfoStatus(info notarize.Info) {
4142
s.Lock.Lock()
4243
defer s.Lock.Unlock()
4344

44-
if info.Status != s.lastStatus {
45-
s.lastStatus = info.Status
46-
color.New().Fprintf(os.Stdout, " %sStatus: %s\n", s.Prefix, info.Status)
45+
if info.Status != s.lastInfoStatus {
46+
s.lastInfoStatus = info.Status
47+
color.New().Fprintf(os.Stdout, " %sInfoStatus: %s\n", s.Prefix, info.Status)
48+
}
49+
}
50+
51+
func (s *statusHuman) LogStatus(log notarize.Log) {
52+
s.Lock.Lock()
53+
defer s.Lock.Unlock()
54+
55+
if log.Status != s.lastLogStatus {
56+
s.lastLogStatus = log.Status
57+
color.New().Fprintf(os.Stdout, " %sLogStatus: %s\n", s.Prefix, log.Status)
4758
}
4859
}
4960

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ go 1.13
55
require (
66
github.com/davecgh/go-spew v1.1.1
77
github.com/fatih/color v1.7.0
8-
github.com/hashicorp/go-cleanhttp v0.5.1
98
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2
109
github.com/hashicorp/go-multierror v1.0.0
11-
github.com/hashicorp/go-retryablehttp v0.6.3
1210
github.com/hashicorp/hcl/v2 v2.0.0
1311
github.com/sebdah/goldie v1.0.0
1412
github.com/stretchr/testify v1.3.0

0 commit comments

Comments
 (0)