Skip to content

Commit

Permalink
INFRA-407: Add maven-set-settings.xml reusable workflow. (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett authored Feb 6, 2024
1 parent 38a9ba3 commit 7b169ec
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 77 deletions.
39 changes: 5 additions & 34 deletions .github/workflows/maven-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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 }}'
19 changes: 11 additions & 8 deletions .github/workflows/maven-check-deps-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}"

Expand Down
41 changes: 6 additions & 35 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-[email protected]
- 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 }}'
64 changes: 64 additions & 0 deletions .github/workflows/maven-set-settings.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}"
}]

0 comments on commit 7b169ec

Please sign in to comment.