diff --git a/.github/settings.xml b/.github/settings.xml new file mode 100644 index 00000000..2a04e7bd --- /dev/null +++ b/.github/settings.xml @@ -0,0 +1,12 @@ + + + + + sonatype + ${env.SONATYPE_USER} + ${env.SONATYPE_PASSWORD} + + + diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..b7838827 --- /dev/null +++ b/.github/workflows/maven.yml @@ -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 diff --git a/pom.xml b/pom.xml index 209a6954..7ccd8b65 100644 --- a/pom.xml +++ b/pom.xml @@ -509,6 +509,15 @@ + + sonatype-oss-snapshot + + + sonatype + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-oss-release