From e5de30845c688433356b3ad275757f1448984d1e Mon Sep 17 00:00:00 2001 From: Lunkle Date: Fri, 21 Feb 2025 18:48:02 -0500 Subject: [PATCH] Also publish to Maven Central on new release creation Update the project to publish to both GitHub Packages and Maven Central on new release creation. * **GitHub Actions Workflow**: - Update `.github/workflows/publish.yml` to include steps for publishing to Maven Central. - Add a new job to publish to Maven Central on release creation. - Use the `maven-publish` action to publish to Maven Central. - Add environment variables for Maven Central credentials. * **POM Configuration**: - Add the Maven Central repository to the `` section in `pom.xml`. - Add necessary plugins and configuration for publishing to Maven Central. * **Settings Configuration**: - Add the Maven Central server configuration in `settings.xml`. - Use environment variables for Maven Central credentials. * **Documentation**: - Update `README.md` to mention automatic deployment to both GitHub Packages and Maven Central. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/virtual-cardboard/nengen?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/publish.yml | 29 ++++++++++++++++++++++++++++- README.md | 4 ++-- pom.xml | 31 +++++++++++++++++++++++++++++++ settings.xml | 5 +++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eff34c8..0a1fc98 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,11 @@ -name: Publish to GitHub Packages +name: Publish to GitHub Packages and Maven Central on: push: branches: - main + release: + types: [created] jobs: build: @@ -26,3 +28,28 @@ jobs: run: mvn deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-to-maven-central: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + + - name: Build with Maven + run: mvn clean install + + - name: Publish to Maven Central + run: mvn deploy + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/README.md b/README.md index c1bb5c7..bf533d8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # nengen The 4th iteration of virtual cardboard's Java game engine. This LWJGL-based engine is an organized yet flexible alternative to LibGDX. -## Automatic Deployment to GitHub Packages +## Automatic Deployment to GitHub Packages and Maven Central -This project is configured to automatically deploy to GitHub Packages using GitHub Actions on each commit to the `main` branch. No manual deployment steps are required. +This project is configured to automatically deploy to GitHub Packages and Maven Central using GitHub Actions on each commit to the `main` branch. No manual deployment steps are required. diff --git a/pom.xml b/pom.xml index 536d172..23c506e 100644 --- a/pom.xml +++ b/pom.xml @@ -223,6 +223,29 @@ + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + @@ -232,6 +255,14 @@ GitHub Packages https://maven.pkg.github.com/virtual-cardboard/nengen + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + diff --git a/settings.xml b/settings.xml index 180bec7..0a9b381 100644 --- a/settings.xml +++ b/settings.xml @@ -5,5 +5,10 @@ ${env.GITHUB_ACTOR} ${env.GITHUB_TOKEN} + + ossrh + ${env.OSSRH_USERNAME} + ${env.OSSRH_PASSWORD} +