From ac65170c76fae273d151a3b03af123c9631f258b Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 28 Jan 2022 13:03:43 +0100 Subject: [PATCH] Polishing #287 --- .github/workflows/ci.yml | 61 +++++++++++++++++++++++++++ .github/workflows/maven.yml | 66 ------------------------------ .github/workflows/pullrequests.yml | 25 +++++++++++ 3 files changed, 86 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/pullrequests.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..98988725 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + 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: ./mvnw -B package + + deploy: + if: github.repository == 'mp911de/logstash-gelf' + 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 snapshots to OSS Sonatype + env: + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: | + if [ "${SONATYPE_USER}" != "" -a "${SONATYPE_PASSWORD}" != "" ]; then + ./mvnw -B clean deploy -Dgpg.skip=true -Dgithub.site.upload.skip=false -P sonatype-oss-snapshot,sonatype-oss-release -s .github/settings.xml + else + echo "Not deploying, secrets SONATYPE_USER and SONATYPE_PASSWORD not provided" + fi diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index b7838827..00000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,66 +0,0 @@ -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/.github/workflows/pullrequests.yml b/.github/workflows/pullrequests.yml new file mode 100644 index 00000000..318b68da --- /dev/null +++ b/.github/workflows/pullrequests.yml @@ -0,0 +1,25 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Build Pull request with Maven + +on: [ pull_request ] + +jobs: + pr-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-pr-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven-pr- + - name: Build with Maven + run: ./mvnw -B verify -D skipITs