I'm learning how to publish android library in mavenCentral, and my first demo with gradle 8.2 published ok. The problem is, my large office projects use gradle 7.3, and so I am decreasing / matching gradle and other dependency versions. I managed to downgrade gradle down to 7.6, but below that I am getting error.
The error:
Error while evaluating property 'signatory' of task ':fortnight-parakeet:signReleasePublication'
> Could not read PGP secret key
> secret key ring doesn't start with secret key tag: tag 0x14
In case you need more logs, gradle created this link: https://scans.gradle.com/s/iju3w74bcov7u , help yourself / feel free to ask me.
What I understand, I need to generate private-public key pairs using gpg such that the private key starts with 0x14.
I followed this tutorial: https://medium.com/mobile-app-development-publication/upload-to-mavencentral-made-easy-for-android-library-30d2b83af0c7
Basically, I invoked this command, and chose the following options.
gpg --full-gen-key
1 # RSA and RSA
4096 # keysize
0 # never expires
# enter name, email, and password
(I'm using ubuntu 22.04, and gnugpg). Then I pushed it onto ubuntu keyserver:
gpg --keyserver keyserver.ubuntu.com --send-keys 12345678 # last 8 characters of public key
And inside my gradle project's root directory, I exported the secret key:
gpg --export-secret-keys 12345678 > my_awesome_secret_key.gpg
I tried a few variations, such as:
gpg --export-secret-keys 12345678 | Base64 > my_awesome_secret_key.gpg
gpg --export-secret-keys 12345678 | Base64 -w0 > my_awesome_secret_key.gpg
gpg --export-secret-keys --armor 12345678 > my_awesome_secret_key.gpg
My gradle file:
Following the above tutorial link, I had created a publish-module.gradle file. The relevant code:
// ... ... ...
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
signing {
useInMemoryPgpKeys( // for gradle version 7.3
"12345678", // rootProject.ext["signing.keyId"],
"my_pass_phrase" // rootProject.ext["signing.password"],
)
// useGpgCmd() // works with gradle 7.6+ , but doesn't work with 7.3, so commented out
sign publishing.publications
}
So, how do I repair this?
Note
In the question I asked for the way to generate gpg key. But there maybe some gradle configurations that could read the current format. So I'm open to solutions as long as it works.
Help.