Skip to content

Merge pull request #718 from eclipse-tractusx/chore/update-DEPENDENCIES #2

Merge pull request #718 from eclipse-tractusx/chore/update-DEPENDENCIES

Merge pull request #718 from eclipse-tractusx/chore/update-DEPENDENCIES #2

Workflow file for this run

name: Upload to Central Maven Registry
on:
workflow_dispatch:
push:
branches:
- main
- release/**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
secret-presence:
runs-on: ubuntu-latest
outputs:
DOCKER_HUB_TOKEN: ${{ steps.secret-presence.outputs.DOCKER_HUB_TOKEN }}
HAS_OSSRH: ${{ steps.secret-presence.outputs.HAS_OSSRH }}
steps:
- name: Check whether secrets exist
id: secret-presence
run: |
[ ! -z "${{ secrets.DOCKER_HUB_TOKEN }}" ] && echo "DOCKER_HUB_TOKEN=true" >> $GITHUB_OUTPUT
[ ! -z "${{ secrets.ORG_GPG_PASSPHRASE }}" ] &&
[ ! -z "${{ secrets.ORG_GPG_PRIVATE_KEY }}" ] &&
[ ! -z "${{ secrets.ORG_OSSRH_USERNAME }}" ] &&
[ ! -z "${{ secrets.ORG_OSSRH_PASSWORD }}" ] &&
echo "HAS_OSSRH=true" >> $GITHUB_OUTPUT
exit 0
publish-to-sonatype:
name: "Publish artifacts to OSSRH Snapshots / MavenCentral"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ secret-presence ]
# do not run on PR branches, do not run on releases
if: |
needs.secret-presence.outputs.HAS_OSSRH && github.event_name != 'pull_request' && github.ref != 'refs/heads/releases'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Import GPG Key
- uses: ./.github/actions/import-gpg-key
name: "Import GPG Key"
with:
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
- name: Configure Maven settings
run: |
mkdir -p $HOME/.m2
echo "<settings xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'>
<servers>
<server>
<id>ossrh</id>
<username>${{ secrets.ORG_OSSRH_USERNAME }}</username>
<password>${{ secrets.ORG_OSSRH_PASSWORD }}</password>
</server>
</servers>
</settings>" > $HOME/.m2/settings.xml
- name: Copy License information
run: |
mkdir -p irs-registry-client/src/main/resources/META-INF/
mkdir -p irs-edc-client/src/main/resources/META-INF/
mkdir -p irs-models/src/main/resources/META-INF/
mkdir -p irs-testing/src/main/resources/META-INF/
mkdir -p irs-common/src/main/resources/META-INF/
cp LICENSE NOTICE.md DEPENDENCIES SECURITY.md irs-registry-client/src/main/resources/META-INF/
cp LICENSE NOTICE.md DEPENDENCIES SECURITY.md irs-edc-client/src/main/resources/META-INF/
cp LICENSE NOTICE.md DEPENDENCIES SECURITY.md irs-models/src/main/resources/META-INF/
cp LICENSE NOTICE.md DEPENDENCIES SECURITY.md irs-testing/src/main/resources/META-INF/
cp LICENSE NOTICE.md DEPENDENCIES SECURITY.md irs-common/src/main/resources/META-INF/
# publish snapshots or releases
- name: Publish version
run: |-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl irs-registry-client)
mvn clean deploy -s $HOME/.m2/settings.xml --batch-mode -Dgpg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}" -Prelease -pl irs-testing,irs-models,irs-edc-client,irs-registry-client,irs-common -Drevision=$VERSION