From 0ab960f5c7a31e1be5dd09bbbb67077aa2e5a5df Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Thu, 12 Dec 2024 16:12:10 -0800 Subject: [PATCH] publish to maven repo --- .github/workflows/gradle.yml | 13 +++++++------ build.gradle | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f78acba..cc24032 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,13 +19,14 @@ jobs: # uses: gradle/gradle-build-action@v2 - name: Restore gradle.properties env: - GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }} + MAVEN_PUBLISH_USERNAME: ${{ secrets.GITHUB_ACTOR }} + MAVEN_PUBLISH_PASSWORD: ${{ secrets.GH_TOKEN }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + SECRET_KEY_RING_FILE: ${{ github.workspace }}/secring.gpg shell: bash run: | - mkdir -p ~/.gradle/ - echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties - echo "signing.secretKeyRingFile=${HOME}/.gradle/secring.gpg" >> ~/.gradle/gradle.properties - echo ${GPG_SIGNING_KEY} | base64 -d > ~/.gradle/secring.gpg + echo ${GPG_SIGNING_KEY} | base64 -d > ${SECRET_KEY_RING_FILE} - name: Run build with Gradle Wrapper - run: ./gradlew test publishToSonatype \ No newline at end of file + run: ./gradlew test publish \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2489f66..954f5f1 100644 --- a/build.gradle +++ b/build.gradle @@ -118,6 +118,15 @@ java { // https://docs.gradle.org/current/userguide/java_library_plugin.html#:~:text=The%20api%20configuration%20should%20be,are%20internal%20to%20the%20component. // https://dev.to/art_ptushkin/gradle-maven-scopes-cheat-sheet-4i56 publishing { + repositories { + maven { + credentials { + username = System.getenv('MAVEN_PUBLISH_USERNAME') ?: '' + password = System.getenv('MAVEN_PUBLISH_PASSWORD') ?: '' + } + url = 'https://maven.pkg.github.com/codeconsole/grails-plugin-sitemesh3' + } + } publications { maven(MavenPublication) { from components.java @@ -165,6 +174,16 @@ publishing { } } +println "***** ${(System.getenv('SIGNING_KEY_ID') ?: '').size()} << length " +println "***** ${(System.getenv('SIGNING_KEY_ID') ?'VALID': 'BLANK')}" +println "***** ${(System.getenv('SIGNING_PASSWORD') ?: '').size()} << length " +println "***** ${(System.getenv('SECRET_KEY_RING_FILE') ?: '').size()} << length " +//signing { + signing.keyId=(System.getenv('SIGNING_KEY_ID') ?: '') + signing.password=System.getenv('SIGNING_PASSWORD') ?: '' + signing.secretKeyRingFile=System.getenv('SECRET_KEY_RING_FILE') ?: '' + + signing { sign publishing.publications.maven }