Publish Gradle Project to Maven Central via CI

We’ve recently completed automated push of Reliza Java Client (SDK) to Maven Central. It’s a Gradle project, so just want to note few things that took more time during this setup.

First, we’re using newer maven-publish plugin. Then note publishing and signing sections in our build.gradle.

Next, our actual build job is here. Note, that it’s an on-demand push that is using technique to use Reliza Hub to route on-demand GitHub Actions builds that I described in my other post.

Finally, biggest issue is how to sign builds in CI. Unfortunately, in-memory signing is poorly documented.

Non-in-memory signing is working as described in Gradle signing plugin documentation – – so that the looks like:


Where secring.gpg is exported via the following command:

gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg

Now, for CI context the recommended way to sign artifacts is in-memory, but unfortunately signing plugin documentation does not provide good way to do that. After a lot of research, the only working solution is presented in this stackoverflow answer:

Which is essentially this:

gpg --armor --export-secret-keys \
    | awk 'NR == 1 { print "GPG_SIGNING_KEY=" } 1' ORS='\\n' \

This creates a workable file that can be used in CI context. And this is the approach we used in the build script.

It would be nice if better documentation is later added to support supplying key via environment variable, but for now I couldn’t find a working solution for that.

Leave a comment

Your email address will not be published. Required fields are marked *