github.com/tiagovtristao/plz@v13.4.0+incompatible/tools/release_signer/main.go (about)

     1  // Package main implements an OpenPGP-compatible signer for our releases.
     2  // It's ultimately easier to have our own, given a solid upstream library for it,
     3  // than managing cross-platform issues with builds.
     4  package main
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  
    10  	"github.com/thought-machine/please/src/cli"
    11  	"github.com/thought-machine/please/tools/release_signer/signer"
    12  )
    13  
    14  var opts = struct {
    15  	Usage    string
    16  	Out      string `short:"o" long:"output" env:"OUT" description:"Output filename (signature)" required:"true"`
    17  	In       string `short:"i" long:"input" description:"Input file to sign" required:"true"`
    18  	Key      string `short:"k" long:"key" env:"PLZ_GPG_KEY" description:"Private ASCII-armoured key file to sign with" required:"true"`
    19  	User     string `short:"u" long:"user" default:"releases@please.build" description:"User to sign for"`
    20  	Password string `short:"p" long:"password" env:"GPG_PASSWORD" required:"true" description:"Password to unlock keyring"`
    21  }{
    22  	Usage: `
    23  release_signer is an internal tool used to sign Please releases with.
    24  
    25  All it can do is create an ASCII-armoured detached signature for a single file.
    26  `,
    27  }
    28  
    29  func main() {
    30  	cli.ParseFlagsOrDie("release_signer", &opts)
    31  	if err := signer.SignFile(opts.In, opts.Out, opts.Key, opts.User, opts.Password); err != nil {
    32  		fmt.Fprintf(os.Stderr, "Signing failed: %s\n", err)
    33  		os.Exit(1)
    34  	}
    35  }