Skip to content

Commit 6cbd3cc

Browse files
committed
feat: sign --detach --ascii
1 parent 20ac295 commit 6cbd3cc

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

internal/pgp/pgp.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ type Seekable interface {
3838
io.Seeker
3939
}
4040

41-
func (s *Signer) DetachSign(in Seekable, out io.Writer) error {
41+
func (s *Signer) DetachSign(in Seekable, out io.Writer, asciiArmour bool) error {
4242
if len(s.entities) == 0 {
4343
return fmt.Errorf("no entities")
4444
}
4545
cfg := &packet.Config{
4646
DefaultHash: crypto.SHA256,
4747
}
48-
if err := openpgp.DetachSign(out, s.entities, in, cfg); err != nil {
49-
return err
48+
if asciiArmour {
49+
return openpgp.ArmoredDetachSign(out, s.entities, in, &openpgp.SignParams{Config: cfg})
5050
}
51-
return nil
51+
return openpgp.DetachSign(out, s.entities, in, cfg)
5252
}
5353

5454
func (s *Signer) ClearSign(in Seekable, out io.Writer) error {

internal/publish/release.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func signRelease(dist string, s *pgp.Signer) error {
156156
if err != nil {
157157
return err
158158
}
159-
if err := s.DetachSign(in, out); err != nil {
159+
if err := s.DetachSign(in, out, false); err != nil {
160160
return err
161161
}
162162
if err := out.Close(); err != nil {

internal/sign/publish.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
type CLI struct {
1111
Files []string `arg:"" help:"Files to sign" type:"existingfile" env:"EZAPT_FILES"`
1212
pgp.CLI
13+
Detach bool `help:"Detach signature" env:"EZAPT_DETACH"`
14+
ASCII bool `help:"ASCII armor" env:"EZAPT_ASCII"`
1315
}
1416

1517
func (c *CLI) Run() error {
@@ -28,7 +30,12 @@ func (c *CLI) Run() error {
2830
if err != nil {
2931
return fmt.Errorf("create: %w", err)
3032
}
31-
if err := sign.ClearSign(in, out); err != nil {
33+
if c.Detach {
34+
err = sign.DetachSign(in, out, c.ASCII)
35+
} else {
36+
err = sign.ClearSign(in, out)
37+
}
38+
if err != nil {
3239
return fmt.Errorf("sign: %w", err)
3340
}
3441
if err := out.Close(); err != nil {

0 commit comments

Comments
 (0)