Skip to content

Commit 2d8db8d

Browse files
committed
Add pkg support for MacOS
Closes #26
1 parent 9cdcec3 commit 2d8db8d

File tree

11 files changed

+105
-24
lines changed

11 files changed

+105
-24
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*.out
1313

1414
go.work
15+
16+
.DS_Store
17+
1518
go.work.sum
1619

1720
# Dependency directories (remove the comment below to include it)

cmd/archivecmd/archive.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func (b *Archivist) Init() error {
7878
// Already started.
7979
return nil
8080
}
81-
infoCtx := c.InfoLog.WithField("plugin", p.ID)
82-
client, err := plugins.StartArchivePlugin(c.InfoLog, c.Config.GoSettings, p)
81+
infoCtx := c.InfoLog.WithField("cmd", fmt.Sprintf("%s %s", commandName, p.ID))
82+
client, err := plugins.StartArchivePlugin(infoCtx, c.Config.GoSettings, p)
8383
if err != nil {
8484
return fmt.Errorf("error starting archive plugin %q: %w", p.ID, err)
8585
}

cmd/corecmd/core.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package corecmd
1616

1717
import (
1818
"context"
19-
"errors"
2019
"flag"
2120
"fmt"
2221
"io"
@@ -33,6 +32,7 @@ import (
3332
"github.com/bep/logg/handlers/multi"
3433
"github.com/bep/workers"
3534
"github.com/gohugoio/hugoreleaser-plugins-api/archiveplugin"
35+
"github.com/gohugoio/hugoreleaser/internal/common/errorsh"
3636
"github.com/gohugoio/hugoreleaser/internal/common/logging"
3737
"github.com/gohugoio/hugoreleaser/internal/common/matchers"
3838
"github.com/gohugoio/hugoreleaser/internal/common/templ"
@@ -415,7 +415,7 @@ func (c *Core) Init() error {
415415
func (c *Core) Close() error {
416416
for k, v := range c.PluginsRegistryArchive {
417417
if err := v.Close(); err != nil {
418-
if !errors.Is(err, execrpc.ErrShutdown) {
418+
if !errorsh.IsShutdownError(err) {
419419
c.WarnLog.Logf("error closing plugin %q: %s", k, err)
420420
}
421421
}

go.mod

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/gohugoio/hugoreleaser
33
go 1.18
44

55
require (
6-
github.com/bep/execrpc v0.7.0
6+
github.com/bep/execrpc v0.7.1
77
github.com/bep/helpers v0.3.1
88
github.com/bep/logg v0.2.0
99
github.com/bep/workers v1.1.0
@@ -29,12 +29,14 @@ require (
2929
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
3030
)
3131

32-
require github.com/gohugoio/hugoreleaser-plugins-api v0.6.0
32+
require (
33+
github.com/gohugoio/hugoreleaser-plugins-api v0.6.0
34+
golang.org/x/sync v0.0.0-20220907140024-f12130a52804
35+
)
3336

3437
require (
3538
github.com/golang/protobuf v1.5.2 // indirect
3639
github.com/google/go-querystring v1.1.0 // indirect
37-
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
3840
google.golang.org/appengine v1.6.7 // indirect
3941
google.golang.org/protobuf v1.28.1 // indirect
4042
)

go.sum

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/bep/clocks v0.5.0 h1:hhvKVGLPQWRVsBP/UB7ErrHYIO42gINVbvqxvYTPVps=
22
github.com/bep/clocks v0.5.0/go.mod h1:SUq3q+OOq41y2lRQqH5fsOoxN8GbxSiT6jvoVVLCVhU=
33
github.com/bep/execrpc v0.7.0 h1:IZneJQielOC2sdHTz/wJTfBgEDxA7WHHMwL1q7d4yB0=
44
github.com/bep/execrpc v0.7.0/go.mod h1:dhMMXFX/IfDRQrp4/EHqqYbYfHS53bF/9kiHIG/ChJw=
5+
github.com/bep/execrpc v0.7.1 h1:ExHlNt9immvo2We9fNnNquXXlGKX1FKrvYNG1ZXd1Fg=
6+
github.com/bep/execrpc v0.7.1/go.mod h1:dhMMXFX/IfDRQrp4/EHqqYbYfHS53bF/9kiHIG/ChJw=
57
github.com/bep/helpers v0.3.1 h1:rvwT4Zuq9VMqTh/OypjKrO/VQE1V0Eyr/PBlfQDcK8E=
68
github.com/bep/helpers v0.3.1/go.mod h1:/QpHdmcPagDw7+RjkLFCvnlUc8lQ5kg4KDrEkb2Yyco=
79
github.com/bep/logg v0.2.0 h1:EWKB04ea/K/V0xd/7O6x5q+1l+Grub+9N48YMcevtF4=
@@ -53,6 +55,7 @@ github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peK
5355
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
5456
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
5557
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
58+
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
5659
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
5760
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
5861
github.com/peterbourgon/ff/v3 v3.3.0 h1:PaKe7GW8orVFh8Unb5jNHS+JZBwWUMa2se0HM6/BI24=
@@ -84,6 +87,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri
8487
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8588
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
8689
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
90+
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
91+
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8792
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8893
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8994
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

hugoreleaser.env

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Next release
2-
# Change counter: 6
3-
HUGORELEASER_TAG=v0.54.0
2+
HUGORELEASER_TAG=v0.55.0
43
HUGORELEASER_COMMITISH=main

hugoreleaser.toml

+37-5
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@ project = "hugoreleaser"
8181
path = "unix"
8282

8383
[[builds.os]]
84-
goos = "darwin"
84+
goos = "linux"
8585
[[builds.os.archs]]
86-
goarch = "universal"
86+
goarch = "amd64"
87+
88+
[[builds]]
89+
path = "macos"
8790

8891
[[builds.os]]
89-
goos = "linux"
92+
goos = "darwin"
9093
[[builds.os.archs]]
91-
goarch = "amd64"
94+
goarch = "universal"
9295

9396
[[builds]]
9497
path = "windows"
@@ -102,6 +105,35 @@ project = "hugoreleaser"
102105

103106
[[archives]]
104107
paths = ["builds/unix/**"]
108+
[[archives]]
109+
paths = ["builds/macos/**"]
110+
[archives.archive_settings]
111+
extra_files = []
112+
[archives.archive_settings.type]
113+
# When format is _plugin,
114+
# archive_settings.plugin must also be configured.
115+
format = "_plugin"
116+
extension = ".pkg"
117+
[archives.archive_settings.plugin]
118+
id = "macospkgremote"
119+
type = "gorun"
120+
# Note there is a "local" variant of this that may be simpler to set up, see
121+
# https://github.com/gohugoio/hugoreleaser-archive-plugins/tree/main/macospkg
122+
command = "github.com/gohugoio/hugoreleaser-archive-plugins/macospkgremote@v0.1.1"
123+
[archives.archive_settings.custom_settings]
124+
# Package settings
125+
package_identifier = "io.gohugo.hugoreleaser"
126+
package_version = "${HUGORELEASER_TAG}"
127+
128+
# Apple settings. Only needed in the "local" variant of this plugin.
129+
# apple_signing_identity = "${BUILDPKG_APPLE_DEVELOPER_SIGNING_IDENTITY}"
130+
131+
# AWS Settings
132+
bucket = "s3fptest"
133+
queue = "https://sqs.eu-north-1.amazonaws.com/656975317043/s3fptest_client"
134+
access_key_id = "${S3RPC_CLIENT_ACCESS_KEY_ID}"
135+
secret_access_key = "${S3RPC_CLIENT_SECRET_ACCESS_KEY}"
136+
105137
[[archives]]
106138
paths = ["builds/**/linux/amd64"]
107139
[archives.archive_settings]
@@ -119,7 +151,7 @@ project = "hugoreleaser"
119151
# If the plugin source lives locally, this can also be a file path,
120152
# e.g. './myplugin'. In those setups you may need to set dir to the directory path,
121153
# and use "." for the command.
122-
command = "github.com/gohugoio/hugoreleaser-archive-plugins/deb@latest"
154+
command = "github.com/gohugoio/hugoreleaser-archive-plugins/deb@v0.6.1"
123155
[archives.archive_settings.custom_settings]
124156
# Custom settings as defined by the Deb plugin.
125157
vendor = "gohugo.io"

internal/common/errorsh/helpers.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package errorsh
2+
3+
import (
4+
"context"
5+
"errors"
6+
7+
"github.com/bep/execrpc"
8+
)
9+
10+
// IsShutdownError returns true if the error is a shutdown error which we normally don't report to the user.
11+
func IsShutdownError(err error) bool {
12+
return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) || errors.Is(err, execrpc.ErrShutdown)
13+
}

internal/common/logging/defaulthandler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func NewDefaultHandler(outWriter, errWriter io.Writer) logg.Handler {
4141
return &DefaultHandler{
4242
outWriter: outWriter,
4343
errWriter: errWriter,
44-
Padding: 3,
44+
Padding: 0,
4545
}
4646
}
4747

@@ -89,7 +89,7 @@ func (h *DefaultHandler) HandleLog(e *logg.Entry) error {
8989
}
9090

9191
if prefix != "" {
92-
prefix = strings.ToUpper(prefix) + ":\t"
92+
prefix = strings.ToLower(prefix) + ": "
9393
}
9494

9595
color.Fprintf(w, "%s %s%s", bold.Sprintf("%*s", h.Padding+1, level), color.Sprint(prefix), e.Message)

main.go

+35-8
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"fmt"
2222
"log"
2323
"os"
24+
"os/signal"
2425
"runtime/debug"
2526
"strings"
27+
"syscall"
2628
"time"
2729

2830
"github.com/bep/logg"
@@ -34,9 +36,12 @@ import (
3436
"github.com/gohugoio/hugoreleaser/internal/common/logging"
3537
"github.com/peterbourgon/ff/v3"
3638
"github.com/peterbourgon/ff/v3/ffcli"
39+
"golang.org/x/sync/errgroup"
3740
)
3841

3942
func main() {
43+
log.SetFlags(0)
44+
4045
if err := parseAndRun(os.Args[1:]); err != nil {
4146
log.Fatal(err)
4247
}
@@ -117,18 +122,40 @@ func parseAndRun(args []string) (err error) {
117122
})
118123

119124
ctx, cancel := context.WithTimeout(context.Background(), core.Timeout)
125+
ctx, _ = signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
120126
defer cancel()
127+
done := make(chan struct{})
121128

122-
if err := core.Init(); err != nil {
123-
return fmt.Errorf("error initializing config: %w", err)
124-
}
129+
g, ctx := errgroup.WithContext(ctx)
125130

126-
if err := coreCommand.Run(ctx); err != nil {
127-
if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
128-
return fmt.Errorf("command timed out after %s; increase -timeout if needed", core.Timeout)
131+
g.Go(func() error {
132+
if err := core.Init(); err != nil {
133+
return fmt.Errorf("error initializing config: %w", err)
129134
}
130-
return fmt.Errorf("error running command: %w", err)
131-
}
135+
if err := coreCommand.Run(ctx); err != nil {
136+
return fmt.Errorf("error running command: %w", err)
137+
}
138+
done <- struct{}{}
139+
return nil
140+
})
141+
142+
g.Go(func() error {
143+
for {
144+
select {
145+
case <-ctx.Done():
146+
err := ctx.Err()
147+
if errors.Is(err, context.DeadlineExceeded) {
148+
log.Fatalf("command timed out after %s; increase -timeout if needed", core.Timeout)
149+
}
150+
return err
151+
case <-done:
152+
return nil
153+
}
154+
}
155+
})
156+
157+
err = g.Wait()
132158

133159
return err
160+
134161
}

testscripts/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)