From ec48ab1848d63c79c1f70a6caac32f76b76f310b Mon Sep 17 00:00:00 2001 From: Amorn Kingthong <37975261+Amorn-Kingthong@users.noreply.github.com> Date: Thu, 10 May 2018 20:01:26 +0000 Subject: [PATCH] Revert "build: specify the key to use when invoking gpg:sign-and-deploy-file (#16696)" This reverts commit eab6e5a317acf67409f82bc5c1f4d959413dfd47. --- build/ci.go | 21 ++++++++------------- internal/build/pgp.go | 12 ------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/build/ci.go b/build/ci.go index 79dcc146c3..204c206752 100644 --- a/build/ci.go +++ b/build/ci.go @@ -755,18 +755,14 @@ func doAndroidArchive(cmdline []string) { os.Rename(archive, meta.Package+".aar") if *signer != "" && *deploy != "" { // Import the signing key into the local GPG instance - b64key := os.Getenv(*signer) - key, err := base64.StdEncoding.DecodeString(b64key) - if err != nil { - log.Fatalf("invalid base64 %s", *signer) - } - gpg := exec.Command("gpg", "--import") - gpg.Stdin = bytes.NewReader(key) - build.MustRun(gpg) - - keyID, err := build.PGPKeyID(string(key)) - if err != nil { - log.Fatal(err) + if b64key := os.Getenv(*signer); b64key != "" { + key, err := base64.StdEncoding.DecodeString(b64key) + if err != nil { + log.Fatalf("invalid base64 %s", *signer) + } + gpg := exec.Command("gpg", "--import") + gpg.Stdin = bytes.NewReader(key) + build.MustRun(gpg) } // Upload the artifacts to Sonatype and/or Maven Central repo := *deploy + "/service/local/staging/deploy/maven2" @@ -775,7 +771,6 @@ func doAndroidArchive(cmdline []string) { } build.MustRunCommand("mvn", "gpg:sign-and-deploy-file", "-e", "-X", "-settings=build/mvn.settings", "-Durl="+repo, "-DrepositoryId=ossrh", - "-Dgpg.keyname="+keyID, "-DpomFile="+meta.Package+".pom", "-Dfile="+meta.Package+".aar") } } diff --git a/internal/build/pgp.go b/internal/build/pgp.go index c7d0d23397..79ab9c06f1 100644 --- a/internal/build/pgp.go +++ b/internal/build/pgp.go @@ -57,15 +57,3 @@ func PGPSignFile(input string, output string, pgpkey string) error { // Generate the signature and return return openpgp.ArmoredDetachSign(out, keys[0], in, nil) } - -// PGPKeyID parses an armored key and returns the key ID. -func PGPKeyID(pgpkey string) (string, error) { - keys, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pgpkey)) - if err != nil { - return "", err - } - if len(keys) != 1 { - return "", fmt.Errorf("key count mismatch: have %d, want %d", len(keys), 1) - } - return keys[0].PrimaryKey.KeyIdString(), nil -}