From 7e6ea02b6d796ceaf85983757b910f4a2b61c6bc Mon Sep 17 00:00:00 2001 From: Dominick Leppich Date: Fri, 3 May 2024 10:17:37 +0200 Subject: [PATCH] ci: update to latest CI scripts --- .github/workflows/develop-build.yml | 67 ++++++++++++++------------- .github/workflows/release-build.yml | 71 ++++++++++++++--------------- Jenkinsfile | 53 +++++++++++++-------- 3 files changed, 100 insertions(+), 91 deletions(-) diff --git a/.github/workflows/develop-build.yml b/.github/workflows/develop-build.yml index 43a0c52..d9c62d8 100644 --- a/.github/workflows/develop-build.yml +++ b/.github/workflows/develop-build.yml @@ -12,37 +12,36 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Check out source code - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Set up Maven cache - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: mvn clean verify -U - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S %Z')" - - name: Create tag name from date - id: tagdate - run: echo "::set-output name=tagdate::$(date +'%Y-%m-%d_%H-%M-%S_%Z')" - - name: Release - id: create_release - uses: softprops/action-gh-release@v2 - with: - name: ${{ steps.date.outputs.date }} - tag_name: ${{ steps.tagdate.outputs.tagdate }} - generate_release_notes: true - draft: false - prerelease: true - files: | - **/target/*.jar - install/* - \ No newline at end of file + - name: Check out source code + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Set up Maven cache + uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + run: mvn clean verify -U -P snapshot-build + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S %Z')" + - name: Create tag name from date + id: tagdate + run: echo "::set-output name=tagdate::$(date +'%Y-%m-%d_%H-%M-%S_%Z')" + - name: Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.date.outputs.date }} + tag_name: ${{ steps.tagdate.outputs.tagdate }} + generate_release_notes: true + draft: false + prerelease: true + files: | + **/target/*.war + install/* diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9e8a022..2ff7685 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -1,48 +1,45 @@ -name: Publish Release Build +name: Publish Development Build + +permissions: + contents: write + +name: Publish Development Build permissions: contents: write on: push: - branches: - - 'master' + tags: + - 'v*' jobs: build: runs-on: ubuntu-latest steps: - - name: Check out source code - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Set up Maven cache - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: mvn clean verify -U - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S %Z')" - - name: Create tag name from date - id: tagdate - run: echo "::set-output name=tagdate::$(date +'%Y-%m-%d_%H-%M-%S_%Z')" - - name: Release - id: create_release - uses: softprops/action-gh-release@v2 - with: - name: ${{ steps.date.outputs.date }} - tag_name: ${{ steps.tagdate.outputs.tagdate }} - generate_release_notes: true - draft: false - prerelease: false - files: | - **/target/*.jar - install/* - \ No newline at end of file + - name: Check out source code + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Set up Maven cache + uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + run: mvn clean verify -U -P release-build + - name: Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + name: Release ${{ github.ref_name }} + generate_release_notes: true + draft: false + prerelease: false + files: | + **/target/*.war + install/* diff --git a/Jenkinsfile b/Jenkinsfile index 4d103f4..d2f4b4b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,54 +22,67 @@ pipeline { } } - stage('build') { + stage('build-snapshot') { + when { + not { + anyOf { + branch 'master' + branch 'release_*' + allOf { + branch 'PR-*' + expression { env.CHANGE_BRANCH.startsWith("release_") } + } + } + } + } steps { - sh 'mvn clean verify -U' - recordIssues enabledForFailure: true, aggregatingResults: true, tools: [java(), javaDoc()] + sh 'mvn clean verify -U -P snapshot-build' } } - - stage('sonarcloud') { + stage('build-release') { when { anyOf { branch 'master' - branch 'sonar_*' + branch 'release_*' + allOf { + branch 'PR-*' + expression { env.CHANGE_BRANCH.startsWith("release_") } + } } } steps { - withCredentials([string(credentialsId: 'jenkins-sonarcloud', variable: 'TOKEN')]) { - sh 'mvn verify sonar:sonar -Dsonar.token=$TOKEN -U' - } + sh 'mvn clean verify -U -P release-build' } } - - stage('deploy-snapshot-libs') { + stage('sonarcloud') { when { anyOf { - branch 'develop' + branch 'master' + branch 'release_*' + branch 'sonar_*' + allOf { + branch 'PR-*' + expression { env.CHANGE_BRANCH.startsWith("release_") } + } } } steps { - script { - if (fileExists('module-lib/pom.xml')) { - sh 'cat pom.xml | grep "SNAPSHOT"' - sh 'mvn -N deploy' - sh 'mvn -f module-lib/pom.xml deploy' - } + withCredentials([string(credentialsId: 'jenkins-sonarcloud', variable: 'TOKEN')]) { + sh 'mvn verify sonar:sonar -Dsonar.token=$TOKEN -U' } } } - stage('deploy-release-libs') { + stage('deploy-libs') { when { anyOf { branch 'master' + branch 'develop' } } steps { script { if (fileExists('module-lib/pom.xml')) { - sh 'cat pom.xml | grep "SNAPSHOT" || true' sh 'mvn -N deploy' sh 'mvn -f module-lib/pom.xml deploy' }