Skip to content

Commit

Permalink
Publish to Maven package to Maven Central instead of GitHub Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
supl committed Nov 20, 2023
1 parent bc38fff commit df98662
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ jobs:
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Upload the package to GitHub Package
- name: Upload the package to Maven Central Repository
run: |
echo "${{ secrets.SIGNING_SECRET_KEY_RING }}" | base64 -d > ~/.gradle/secring.gpg
./gradlew publish \
-PprojVersion="${{ steps.version.outputs.version }}" \
-PgprUsername="${{ github.repository_owner }}" \
-PgprPassword="${{ secrets.CR_PAT }}"
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
-Psigning.password="${{ secrets.SIGNING_PASSWORD }}" \
-Psigning.secretKeyRingFile="$(echo ~/.gradle/secring.gpg)" \
-PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \
-PossrhPassword="${{ secrets.OSSRH_PASSWORD }}"
- name: Build the shadow Jar
run: ./gradlew shadowJar
Expand Down
13 changes: 10 additions & 3 deletions lib/archive.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
Expand Down Expand Up @@ -37,11 +38,17 @@ publishing {
}
repositories {
maven {
url = uri("https://maven.pkg.github.com/scalar-labs/scalar-admin-k8s")
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.findProperty("gprUsername") ?: System.getenv("GPR_USERNAME")
password = project.findProperty("gprPassword") ?: System.getenv("GPR_PASSWORD")
username = "${ossrhUsername}"
password = "${ossrhPassword}"
}
}
}
}

signing {
sign publishing.publications.mavenJava
}

0 comments on commit df98662

Please sign in to comment.