Skip to content

Commit

Permalink
Improve GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ben221199 committed May 20, 2024
1 parent ba246a0 commit 3735fe8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
34 changes: 12 additions & 22 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<version>1.0.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -52,4 +52,12 @@
</plugins>
</build>

<distributionManagement>
<repository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

</project>

0 comments on commit 3735fe8

Please sign in to comment.