Skip to content

Commit

Permalink
chore: Enhance GitHub Actions workflow with Java setup and Maven caching
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Nov 22, 2024
1 parent 277ca61 commit 2485a5b
Showing 1 changed file with 59 additions and 15 deletions.
74 changes: 59 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,52 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-
- name: Write maven settings
uses: whelk-io/maven-settings-xml-action@v20
with:
repositories: |
[
{
"id": "ossrh",
"url": "https://s01.oss.sonatype.org/content/repositories/snapshots",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true"
}
}
]
servers: >
[
{
"id": "ossrh",
"username": "${{secrets.OSSRH_USERNAME}}",
"password": "${{secrets.OSSRH_TOKEN}}"
}
]
profiles: >
[
{
"id": "ossrh",
"activation": {
"activeByDefault": true
}
}
]
- name: Set version with SNAPSHOT if not creating a release
id: set_version
Expand All @@ -35,9 +81,6 @@ jobs:
echo "VERSION=${{ env.VERSION }}" >> $GITHUB_ENV
fi
- name: Install Maven
run: sudo apt install maven

- name: Bump version in POM files
run: mvn versions:set -DnewVersion=${{ env.VERSION }} -q

Expand Down Expand Up @@ -80,6 +123,19 @@ jobs:
- name: Write maven settings
uses: whelk-io/maven-settings-xml-action@v20
with:
repositories: |
[
{
"id": "ossrh",
"url": "https://s01.oss.sonatype.org/content/repositories/snapshots",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true"
}
}
]
servers: >
[
{
Expand All @@ -94,18 +150,6 @@ jobs:
"id": "ossrh",
"activation": {
"activeByDefault": true
},
"repositories": {
"repository": {
"id": "ossrh",
"url": "https://s01.oss.sonatype.org/content/repositories/snapshots",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true"
}
}
}
}
]
Expand Down

0 comments on commit 2485a5b

Please sign in to comment.