From 941cf26ad4ac47731f446e5199ef4cc4c5430aed Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Fri, 20 Dec 2024 11:55:53 +0100 Subject: [PATCH] No issue: Try deploying snapshot builds to Nexus --- .github/workflows/codeql.yml | 6 ++-- .github/workflows/maven.yml | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fb3893fc6..03d1e5082 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,10 +13,10 @@ name: "CodeQL" on: push: - branches: [ "main", "main-v2", "rel/*" ] + branches: [ "main", "release/**" ] pull_request: # The branches below must be a subset of the branches above - branches: [ "main", "main-v2", "rel/*" ] + branches: [ "main", "release/**" ] schedule: - cron: '30 20 * * 0' @@ -53,7 +53,7 @@ jobs: - name: Set up Maven uses: stCarolas/setup-maven@v5 with: - maven-version: 3.9.8 + maven-version: 3.9.9 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..a450621fd --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,61 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "main", "release/**" ] + pull_request: + branches: [ "main", "release/**" ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + os: [ubuntu-latest, windows-latest] + jdk: [17] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref || github.ref }} + + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'temurin' + cache: maven + server-id: apache.snapshots.https + server-username: NEXUS_USERNAME + server-password: NEXUS_PASSWORD + + - name: Set up Maven + uses: stCarolas/setup-maven@v5 + with: + maven-version: 3.9.9 + + - name: Set up cache date + run: echo "CACHE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: Build with Maven + run: mvn --show-version --batch-mode --no-transfer-progress clean verify + + - name: Upload to Nexus + if: matrix.os == 'ubuntu-latest' + env: + # `NEXUS_USERNAME` and `NEXUS_PASSWORD` are used in `~/.m2/settings.xml` created by `setup-java` action + NEXUS_USERNAME: ${{ secrets.NEXUS_USER }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PW }} + run: mvn --show-version --batch-mode --errors --no-transfer-progress deploy