diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f78acba..ea453d0 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,17 +15,10 @@ jobs: distribution: 'liberica' java-version: '17' cache: 'gradle' - # - name: Setup Gradle - # uses: gradle/gradle-build-action@v2 - - name: Restore gradle.properties - env: - GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }} - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - 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 - name: Run build with Gradle Wrapper - run: ./gradlew test publishToSonatype \ No newline at end of file + env: + MAVEN_PUBLISH_USERNAME: ${{ secrets.GITHUB_ACTOR }} + MAVEN_PUBLISH_PASSWORD: ${{ secrets.GH_TOKEN }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew test publish \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2489f66..8911c4c 100644 --- a/build.gradle +++ b/build.gradle @@ -118,6 +118,17 @@ 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 { + if (!project.version.toString().endsWith('SNAPSHOT')) { + 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,8 +176,11 @@ publishing { } } -signing { - sign publishing.publications.maven +if (!project.version.toString().endsWith('SNAPSHOT')) { + signing { + useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD')) + sign publishing.publications.maven + } } nexusPublishing {