diff --git a/.github/workflows/maven-build-test.yml b/.github/workflows/maven-build-test.yml index b450bb1..c234679 100644 --- a/.github/workflows/maven-build-test.yml +++ b/.github/workflows/maven-build-test.yml @@ -30,42 +30,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK ${{ inputs.java-version }} - uses: actions/setup-java@v4 + - name: Set settings + uses: mekomsolutions/shared-github-workflow/.github/workflows/maven-set-settings.yml@main with: java-version: ${{ inputs.java-version }} - distribution: ${{ inputs.java-distribution }} - cache: 'maven' - - - name: Set settings.xml - uses: s4u/maven-settings-action@v3.0.0 - with: - servers: | - [{ - "id": "mks-private-repo", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-public-snapshots", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-public-releases", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-private-snapshots", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-private-releases", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }] + java-distribution: ${{ inputs.java-distribution }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} - name: Build with Maven run: 'mvn --batch-mode --update-snapshots clean verify ${{ inputs.maven-args }}' diff --git a/.github/workflows/maven-check-deps-build-publish.yml b/.github/workflows/maven-check-deps-build-publish.yml index dac8e8c..69ed141 100644 --- a/.github/workflows/maven-check-deps-build-publish.yml +++ b/.github/workflows/maven-check-deps-build-publish.yml @@ -34,12 +34,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK ${{ inputs.java-version }} - uses: actions/setup-java@v4 + - name: Set settings.xml + uses: mekomsolutions/shared-github-workflow/.github/workflows/maven-set-settings.yml@main with: java-version: ${{ inputs.java-version }} - distribution: ${{ inputs.java-distribution }} - cache: 'maven' + java-distribution: ${{ inputs.java-distribution }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} - name: Check for dependency changes id: compareDependencyChanges @@ -114,12 +115,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK ${{ inputs.java-version }} - uses: actions/setup-java@v4 + - name: Set settings.xml + uses: mekomsolutions/shared-github-workflow/.github/workflows/maven-set-settings.yml@main with: - distribution: ${{ inputs.java-distribution }} java-version: ${{ inputs.java-version }} - cache: "maven" + java-distribution: ${{ inputs.java-distribution }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} + - name: Build run: "mvn --batch-mode clean package ${{ inputs.maven-args }}" diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index be27e81..9e1a886 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -30,43 +30,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Set up JDK ${{ inputs.java-version }} - uses: actions/setup-java@v4 - with: - java-version: ${{ inputs.java-version }} - distribution: ${{ inputs.java-distribution }} - cache: 'maven' - - name: Set settings.xml - uses: s4u/maven-settings-action@v3.0.0 + - name: Set settings + uses: mekomsolutions/shared-github-workflow/.github/workflows/maven-set-settings.yml@main with: - servers: | - [{ - "id": "mks-private-repo", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-public-snapshots", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-public-releases", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-private-snapshots", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }, - { - "id": "mks-nexus-private-releases", - "username": "${{ secrets.NEXUS_USERNAME }}", - "password": "${{ secrets.NEXUS_PASSWORD }}" - }] + java-version: ${{ inputs.java-version }} + java-distribution: ${{ inputs.java-distribution }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} - name: Publish maven artifacts run: 'mvn --batch-mode clean deploy ${{ inputs.maven-args }}' diff --git a/.github/workflows/maven-set-settings.yml b/.github/workflows/maven-set-settings.yml new file mode 100644 index 0000000..e53fecc --- /dev/null +++ b/.github/workflows/maven-set-settings.yml @@ -0,0 +1,64 @@ +name: Maven Set settings.xml + +on: + workflow_call: + inputs: + java-version: + description: 'Java version to use for building' + required: false + type: string + default: '17' + java-distribution: + description: 'Java distribution to use for building' + required: false + type: string + default: 'temurin' + nexus-username: + description: 'Username for the Nexus repository' + required: true + type: string + nexus-password: + description: 'Password for the Nexus repository' + required: true + type: string + +jobs: + set-settings: + runs-on: ubuntu-latest + steps: + - name: Set up JDK ${{ inputs.java-version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.java-version }} + distribution: ${{ inputs.java-distribution }} + cache: 'maven' + + - name: Set settings.xml + uses: s4u/maven-settings-action@v3.0.0 + with: + servers: | + [{ + "id": "mks-private-repo", + "username": "${{ inputs.nexus-username }}", + "password": "${{ inputs.nexus-password }}" + }, + { + "id": "mks-nexus-public-snapshots", + "username": "${{ inputs.nexus-username }}", + "password": "${{ inputs.nexus-password }}" + }, + { + "id": "mks-nexus-public-releases", + "username": "${{ inputs.nexus-username }}", + "password": "${{ inputs.nexus-password }}" + }, + { + "id": "mks-nexus-private-snapshots", + "username": "${{ inputs.nexus-username }}", + "password": "${{ inputs.nexus-password }}" + }, + { + "id": "mks-nexus-private-releases", + "username": "${{ inputs.nexus-username }}", + "password": "${{ inputs.nexus-password }}" + }]