Skip to content

Commit

Permalink
publish to maven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole committed Dec 13, 2024
1 parent bbcb251 commit 6b877cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
18 changes: 16 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6b877cb

Please sign in to comment.