Skip to content

Commit

Permalink
EDC extension - Maven Central publish
Browse files Browse the repository at this point in the history
- Adds plugin configurations
- Includes the LICENSE, NOTICE and DEPENDENCIES files in the jar
- Defines required project properties for the EDC module
- Adds Distribution management for both GitHub and OSSRH
- Defines new workflow to publish artifact to Maven Central
- Adds triggers to the existing release workflows
- Defines release-to-central profile for release builds

Updates #352

Signed-off-by: Istvan Zoltan Nagy <[email protected]>
  • Loading branch information
istvan-nagy-epam committed Apr 8, 2024
1 parent 381da60 commit e21f8fe
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 13 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/hotfix-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ on:
version:
description: 'Version'
required: true
release_docker_image:
description: 'Should we release the Docker image?'
required: true
default: 'yes'
type: choice
options:
- 'yes'
- 'no'
release_edc:
description: 'Should we release the EDC extension?'
required: true
default: 'yes'
type: choice
options:
- 'yes'
- 'no'

jobs:
build:
Expand Down Expand Up @@ -59,8 +75,16 @@ jobs:
git tag v${{ inputs.version }}
git push origin v${{ inputs.version }}
call-image-release:
if: ${{ inputs.release_docker_image == 'yes' }}
uses: ./.github/workflows/publish-image-registry.yml
needs: build
secrets: inherit
with:
tag: v${{ inputs.version }}
call-edc-maven-central-publish:
if: ${{ inputs.release_edc == 'yes' }}
uses: ./.github/workflows/publish-edc-ext-to-maven-central.yml
needs: build
secrets: inherit
with:
tag: v${{ inputs.version }}
76 changes: 76 additions & 0 deletions .github/workflows/publish-edc-ext-to-maven-central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
################################################################################
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH and others
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
################################################################################

---

name: Publish EDC extension to Maven Central

on:
workflow_dispatch:
inputs:
tag:
type: string
description: The name of the tag from which we would like to build an artifact
required: true

jobs:
maven-release:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout if workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: setup-java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Setup Maven Action
uses: s4u/[email protected]
with:
java-version: 17
- name: List Keys (set up GPG)
shell: bash
run: |
gpg -K --keyid-format=long
- name: Import GPG Private Key
shell: bash
run: |
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo -e "${{ secrets.ORG_GPG_PRIVATE_KEY }}" | gpg --import --batch
for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
do
echo -e "5\\ny\\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
- name: Publish to the Maven Central Repository
shell: bash
run: |
mvn clean verify nexus-staging:deploy -Dgpg.passphrase=${{ secrets.ORG_GPG_PASSPHRASE }} -f libraries/edc-extension/pom.xml -P release-to-central
env:
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ on:
version:
description: 'Version'
required: true
release_docker_image:
description: 'Should we release the Docker image?'
required: true
default: 'yes'
type: choice
options:
- 'yes'
- 'no'
release_edc:
description: 'Should we release the EDC extension?'
required: true
default: 'yes'
type: choice
options:
- 'yes'
- 'no'

jobs:
build:
Expand Down Expand Up @@ -64,8 +80,16 @@ jobs:
git push origin release
git push origin v${{ inputs.version }}
call-image-release:
if: ${{ inputs.release_docker_image == 'yes' }}
uses: ./.github/workflows/publish-image-registry.yml
needs: build
secrets: inherit
with:
tag: v${{ inputs.version }}
call-edc-maven-central-publish:
if: ${{ inputs.release_edc == 'yes' }}
uses: ./.github/workflows/publish-edc-ext-to-maven-central.yml
needs: build
secrets: inherit
with:
tag: v${{ inputs.version }}
74 changes: 64 additions & 10 deletions libraries/edc-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@
<packaging>jar</packaging>

<organization>
<name>${organization}</name>
<url>${url}</url>
<name>Tractus-X project</name>
<url>https://projects.eclipse.org/projects/automotive.tractusx</url>
</organization>

<scm>
<url>https://github.com/eclipse-tractusx/sldt-digital-twin-registry/</url>
<connection>scm:git:https://github.com/eclipse-tractusx/sldt-digital-twin-registry.git</connection>
<developerConnection>scm:git:https://github.com/eclipse-tractusx/sldt-digital-twin-registry.git</developerConnection>
</scm>

<licenses>
<license>
<name>${licence_name}</name>
<url>${licence_url}</url>
<distribution>${licence_distribution}</distribution>
<comments>${licence_comments}</comments>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>An Eclipse Project</comments>
</license>
</licenses>

Expand Down Expand Up @@ -111,26 +117,74 @@
</dependencies>

<build>
<resources>
<resource>
<directory>${project.parent.basedir}</directory>
<includes>
<include>LICENSE</include>
<include>NOTICE.md</include>
<include>DEPENDENCIES</include>
</includes>
<targetPath>META-INF/</targetPath>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release-to-central</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

</project>
58 changes: 55 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,67 @@
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<!-- TODO: change to true! -->
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down

0 comments on commit e21f8fe

Please sign in to comment.