From 3735fe8d964fe58f4ddc21a564055ee1bc3cb70b Mon Sep 17 00:00:00 2001 From: Ben van Hartingsveldt Date: Mon, 20 May 2024 19:22:24 +0200 Subject: [PATCH] Improve GitHub actions --- .github/workflows/maven-publish.yml | 34 ++++++++++------------------- .github/workflows/maven.yml | 4 ++-- pom.xml | 12 ++++++++-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 2cd34f6..1d975f5 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -1,34 +1,24 @@ -# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path - -name: Maven Package +name: Publish package to the Maven Central Repository on: release: types: [created] jobs: - build: - + publish: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up Maven Central Repository + uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '8' distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Build with Maven - run: mvn -B package --file pom.xml - - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Publish package + run: mvn --batch-mode deploy env: - GITHUB_TOKEN: ${{ github.token }} + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cca26d5..6b3cdb1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 8 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '8' distribution: 'temurin' cache: maven - name: Build with Maven diff --git a/pom.xml b/pom.xml index 7c4922f..da30b88 100644 --- a/pom.xml +++ b/pom.xml @@ -8,8 +8,8 @@ 1.0.0-SNAPSHOT - 17 - 17 + 8 + 8 UTF-8 @@ -52,4 +52,12 @@ + + + ossrh + Central Repository OSSRH + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + \ No newline at end of file