CI KADAI adapter #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI KADAI adapter | |
on: | |
workflow_dispatch: | |
push: | |
branches-ignore: | |
- dependabot/** | |
tags: | |
- '[0-9]+\.[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\.[0-9]+' | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 3 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.repository }}/${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
JAVA_VERSION: 17 | |
CACHE_MAVEN_NAME: ma2aen | |
CACHE_SONAR_NAME: sonar | |
ARTIFACTS_JACOCO_REPORTS_NAME: jacoco-reports | |
ARTIFACTS_JACOCO_REPORTS_PATH: '**/jacoco.exec' | |
jobs: | |
compile_and_test: | |
name: Test | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK ${{ env.JAVA_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Cache maven dependencies | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }} | |
- name: Test | |
run: ./mvnw -B verify | |
- name: Upload JaCoCo Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACTS_JACOCO_REPORTS_NAME }} | |
path: ${{ env.ARTIFACTS_JACOCO_REPORTS_PATH }} | |
if-no-files-found: ignore | |
- name: Remove kadai artifacts from cache | |
run: rm -rf ~/.m2/repository/io/kadai | |
release_artifacts: | |
runs-on: ubuntu-20.04 | |
name: Release artifacts to OSS Sonatype | |
if: github.repository == 'kadai-io/KadaiAdapter' && ( startsWith(github.ref, 'refs/tags')) && github.head_ref == '' | |
needs: [ compile_and_test ] | |
# as documented in the gpg manual (https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html) | |
# we should execute this command before interacting with gpg (otherwise gpg won't work) | |
env: | |
GPG_TTY: $(tty) | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # necessary for push back | |
# NOTE @v2 uses the token as an auth http header. Set it to | |
# a Personal Access Token instead of secrets.GITHUB_TOKEN | |
# so that tag pushes trigger repo push events. | |
# source: https://github.saobby.my.eu.orgmunity/t/action-does-not-trigger-another-on-push-tag-action/17148/7 | |
token: ${{ secrets.ADMIN_PERSONAL_ACCESS_TOKEN }} | |
- name: Set up JDK ${{ env.JAVA_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Cache maven dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }} | |
- name: Import GPG Key | |
run: echo -n "$GPG_KEY" | base64 --decode | gpg --batch --import | |
env: | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
- name: Change versions to match tag | |
run: ci/change_version.sh -m . | |
- name: Release artifacts to OSS Sonatype | |
run: | | |
./mvnw -B deploy -P $([[ "$GITHUB_REF" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "release") \ | |
--settings ci/mvnsettings.xml -DskipTests -Dcheckstyle.skip -Djacoco.skip \ | |
-pl :kadai-adapter-parent,\ | |
:kadai-adapter,:kadai-adapter-camunda-system-connector,:kadai-adapter-kadai-connector,\ | |
:kadai-adapter-camunda-listener,:kadai-adapter-camunda-outbox-rest,\ | |
:kadai-adapter-camunda-outbox-rest-spring-boot-starter | |
env: | |
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
- name: Update version to next snapshot and push back | |
run: | | |
ci/change_version.sh -i -m . | |
ci/commitPoms.sh | |
env: | |
GH_EMAIL: ${{ secrets.GH_EMAIL }} | |
GH_USERNAME: ${{ secrets.GH_USERNAME }} | |
- name: Remove kadai artifacts from cache | |
run: rm -rf ~/.m2/repository/io/kadai | |
- name: Cancel workflow | |
if: failure() | |
uses: andymckay/cancel-action@0.5 | |
upload_to_sonar: | |
runs-on: ubuntu-20.04 | |
name: Upload SonarQube analysis to sonarcloud | |
# no pull request and not on release | |
if: github.head_ref == '' && !startsWith(github.ref, 'refs/tags') | |
needs: [ compile_and_test ] | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up JDK ${{ env.JAVA_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-${{ env.CACHE_SONAR_NAME }} | |
restore-keys: ${{ runner.os }}-${{ env.CACHE_SONAR_NAME }} | |
- name: Cache maven dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-${{ env.CACHE_MAVEN_NAME }} | |
- name: Download JaCoCo reports | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACTS_JACOCO_REPORTS_NAME }} | |
- name: Install kadai adapter | |
run: ./mvnw -B install -DskipTests -Dcheckstyle.skip -Dmaven.javadoc.skip | |
- name: Upload SonarQube analysis | |
run: ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} | |
- name: Remove kadai artifacts from cache | |
run: rm -rf ~/.m2/repository/io/kadai | |
- name: Cancel workflow | |
if: failure() | |
uses: andymckay/cancel-action@0.5 |