Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Use Github Actions to build and deploy snapshots #287
Browse files Browse the repository at this point in the history
  • Loading branch information
sfuhrm authored Jan 28, 2022
1 parent f6eed5d commit c29e53a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<servers>
<server>
<id>sonatype</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
66 changes: 66 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Java CI with Maven

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
steps:

- uses: actions/checkout@v2

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: temurin

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package --file pom.xml

deploy:
runs-on: ubuntu-latest
needs: [ build ]
steps:

- uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: temurin

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy with Maven to SONATYPE OSS Snapshot if secrets are set
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
if [ "${SONATYPE_USER}" != "" -a "${SONATYPE_PASSWORD}" != "" ]; then
mvn -B deploy -P sonatype-oss-snapshot -s .github/settings.xml
else
echo "Not deploying, secrets SONATYPE_USER and SONATYPE_PASSWORD not provided"
fi
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@
</reporting>

<profiles>
<profile>
<id>sonatype-oss-snapshot</id>
<distributionManagement>
<snapshotRepository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>
<profile>
<id>sonatype-oss-release</id>
<build>
Expand Down

0 comments on commit c29e53a

Please sign in to comment.