From e6c7353d863b8d552528607e83e994cd81f8ef0e Mon Sep 17 00:00:00 2001 From: Jk Date: Wed, 14 Jul 2021 16:39:31 +0200 Subject: [PATCH] In progress migration to GH actions --- .github/workflows/build_sonar_verify.yml | 37 +++++++++++++++++++ .github/workflows/bump-pom.yml | 46 ++++++++++++++++++++++++ .github/workflows/deploy.yml | 35 ++++++++++++++++++ .github/workflows/maven-verify.yml | 28 +++++++++++++++ .settings.xml | 3 +- 5 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_sonar_verify.yml create mode 100644 .github/workflows/bump-pom.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/maven-verify.yml diff --git a/.github/workflows/build_sonar_verify.yml b/.github/workflows/build_sonar_verify.yml new file mode 100644 index 00000000..02a35686 --- /dev/null +++ b/.github/workflows/build_sonar_verify.yml @@ -0,0 +1,37 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Cache SonarCloud packages + uses: actions/cache@v2 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar diff --git a/.github/workflows/bump-pom.yml b/.github/workflows/bump-pom.yml new file mode 100644 index 00000000..c56d8e8e --- /dev/null +++ b/.github/workflows/bump-pom.yml @@ -0,0 +1,46 @@ +name: Bump POM +on: + push: + branches: + - master +jobs: + bump_pom: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Expose git commit data + uses: rlespinasse/git-commit-data-action@v1.x + + - name: Bump pom patch version for fixes and clean + run: | + mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DprocessAllModules versions:commit + if: "contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'Merge pull request') && + (contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'fix') || contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'clean'))" + + - name: Bump pom minor version for feature + run: | + mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 -DprocessAllModules versions:commit + if: "contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'Merge pull request') && contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'feature')" + + - name: Bump pom major version for major feature + run: | + mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 -DprocessAllModules versions:commit + if: "contains(env.commit_message, 'Merge pull request') && + (contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'clean') || contains(env.GIT_COMMIT_MESSAGE_SUBJECT , 'major'))" + - name: Retrieve the version + run: | + echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + + - name: Commit and tag + uses: EndBug/add-and-commit@v7.2.1 + with: + add: "['pom.xml', './**/pom.xml']" + default_author: github_actions + message: Bump pom + tag: ${{ env.version }} + if: "contains(env.commit_message, 'Merge pull request')" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..724634a4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Deploy to maven repository after bump pom + +on: + push: + tags: + - "\d.\d.\d" + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.actor == '' }} + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + + - name: Publish to Apache Maven Central + run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent -DskipTests deploy sonar:sonar --settings .settings.xml -P release,ossrh + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Upload the Jars + uses: actions/upload-artifact@v2 + with: + path: /**/target/*.jar + + # Remains upload jar artifacts + # Create the release https://github.com/marketplace/actions/gh-release?version=v0.1.5 + release: diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml new file mode 100644 index 00000000..593e4542 --- /dev/null +++ b/.github/workflows/maven-verify.yml @@ -0,0 +1,28 @@ +name: Java CI + +on: [push] + +jobs: + verify: + runs-on: ubuntu-latest + concurrency: ci-${{ github.ref }} + strategy: + matrix: + java: ['8', '11', '13', '15'] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'adopt' + - name: Cache maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Run the maven verify + run: mvn --batch-mode --update-snapshots clean verify diff --git a/.settings.xml b/.settings.xml index 1c90cb5f..ec9cefcc 100644 --- a/.settings.xml +++ b/.settings.xml @@ -16,9 +16,8 @@ false - ${env.GPG_EXECUTABLE} ${env.GPG_PASSPHRASE} - \ No newline at end of file +