After watching <Martin Bonnin's talk at KotlinConf...
# gradle
a
After watching

Martin Bonnin's talk at KotlinConf about building libraries

, I was inspired to migrate my libraries from JitPack to Maven Central, using the gradle-maven-publish-plugin he recommended. Having never worked with signing before, I'm unsure whether my failing
signMavenPublication
task is due to the plugin itself, or the underlying
signing
plugin. The signing plugin gives instructions to provide your GPG keys using a system keychain (not feasible in CI), but the
gradle-maven-publish-plugin
provides instructions to use an in-memory key via ENV. I've set the following variables in my CI: • ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD • ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME • ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY • ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD • ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID (optional) Where the maven central credentials are from a generated user token (since I signed in to central with Github) and my gradle file is configure like so:
Copy code
mavenPublishing {
    configure(KotlinJvm(sourcesJar = true))
    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
    signAllPublications()
    coordinates("dev.andrewohara", "service-utils", "1.20.0")

    pom {
        ...
    }
}
However, after running
Copy code
$ sh ./gradlew publish --no-configuration-cache
I get
Copy code
Execution failed for task ':signMavenPublication'.
> Cannot perform signing task ':signMavenPublication' because it has no configured signatory
Common suggestions I've seen point to a missing variable, but I think I have them all. Does anyone have any advice?
e
environment variables are case sensitive, you're not setting the right ones if you use all-caps
1
a
Github Actions is overriding the casing 😅
e
… are you using a windows runner?
a
Not for the publish job
It's in the settings itself, so don't think the runner makes a difference
e
oh that. secrets are not placed into the environment automatically
no need to name the secrets the same as the environment variables since you have to map them per step or job anyway
Copy code
jobs:
  publish:
    steps:
      - run: |
          ./gradlew publish
        env:
          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
a
Ah! I'm not super familiar with GH actions, so I'm not surprised this tripped me up. Thanks for the advice!
That fixed the problem, thank you!