Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright(c) 2026 Sven Trittler
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

name: Release to Maven Central
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build and verify universal artifacts
uses: ./.github/workflows/universal.yml

publish:
name: Publish release to Maven Central
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
MAVEN_ARGS: --settings "${{ github.workspace }}/.github/maven-settings.xml"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '17'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
overwrite-settings: false
cache: maven
cache-dependency-path: |
pom.xml
maven/pom.xml
src/buildtools/pom.xml
.github/maven-settings.xml
# The Central publishing extension requires Maven 3.
- uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
with:
maven-version: '3.9.9'
- uses: actions/download-artifact@v8
with:
name: universal-java
path: release
- name: Sign and publish the verified universal artifacts
env:
RELEASE_TAG: ${{ github.ref_name }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
shell: bash
run: |
for KEY in MAVEN_CENTRAL_USERNAME MAVEN_CENTRAL_PASSWORD GPG_KEY_ID MAVEN_GPG_PASSPHRASE; do
if [ -z "${!KEY}" ]; then echo "::error::Missing publishing environment variable: $KEY"; exit 1; fi
done
python3 scripts/check-release-tag.py "$RELEASE_TAG"
VERSION=$RELEASE_TAG
mvn -B -ntp -f maven/pom.xml -Prelease-artifacts,central-release \
"-Dcyclonedds.runtime.jar=$PWD/release/org.eclipse.cyclonedds-${VERSION}.jar" \
"-Dcyclonedds.idlc.verifiedJar=$PWD/release/org.eclipse.cyclonedds.idlc-${VERSION}.jar" \
"-Dgpg.keyname=$GPG_KEY_ID" deploy
- name: Save signed deployment bundle
if: always()
uses: actions/upload-artifact@v7
with:
name: maven-central-deployment
path: '**/target/central-publishing/*.zip'
if-no-files-found: ignore
56 changes: 3 additions & 53 deletions .github/workflows/universal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
name: Universal Java distribution
on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:
workflow_call:
permissions:
contents: read
concurrency:
Expand Down Expand Up @@ -261,56 +264,3 @@ jobs:
subprocess.run([sys.executable, "tests/idlc_bundle.py", str(java / "java"), str(java / "javac"),
str(root / "release" / f"org.eclipse.cyclonedds.idlc-{version}.jar"),
str(root / "release" / f"org.eclipse.cyclonedds-{version}.jar"), str(root)], check=True)

publish:
name: Publish release to Maven Central
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: verify-universal
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '17'
cache: maven
cache-dependency-path: |
pom.xml
maven/pom.xml
src/buildtools/pom.xml
.github/maven-settings.xml
# The Central publishing extension requires Maven 3.
- uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
with:
maven-version: '3.9.9'
- uses: actions/download-artifact@v8
with:
name: universal-java
path: release
- name: Sign and publish the verified universal artifacts
env:
RELEASE_TAG: ${{ github.ref_name }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
MAVEN_GPG_KEY_FINGERPRINT: ${{ secrets.MAVEN_GPG_KEY_FINGERPRINT }}
shell: bash
run: |
for KEY in MAVEN_CENTRAL_USERNAME MAVEN_CENTRAL_PASSWORD MAVEN_GPG_KEY MAVEN_GPG_PASSPHRASE; do
if [ -z "${!KEY}" ]; then echo "::error::Missing GitHub Actions secret: $KEY"; exit 1; fi
done
python3 scripts/check-release-tag.py "$RELEASE_TAG"
VERSION=$RELEASE_TAG
mvn -B -ntp -f maven/pom.xml -Prelease-artifacts,central-release \
"-Dcyclonedds.runtime.jar=$PWD/release/org.eclipse.cyclonedds-${VERSION}.jar" \
"-Dcyclonedds.idlc.verifiedJar=$PWD/release/org.eclipse.cyclonedds.idlc-${VERSION}.jar" \
deploy
- name: Save signed deployment bundle
if: always()
uses: actions/upload-artifact@v7
with:
name: maven-central-deployment
path: '**/target/central-publishing/*.zip'
if-no-files-found: ignore
43 changes: 23 additions & 20 deletions docs/manual/maven.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,12 @@ before tagging.
Publishing a release
--------------------

Pushing a tag ``X.Y.Z`` (for example ``11.0.1``) runs the normal platform builds and tests,
The ``Release to Maven Central`` workflow (``.github/workflows/release.yml``) runs
on pushed tags matching ``[0-9]+.[0-9]+.[0-9]+*``. It calls the reusable
``universal.yml`` workflow for the normal platform builds and tests,
then automatically publishes to Maven Central after all five universal-JAR host
checks pass. The tag version must match the
checks pass. The existing version check requires ``X.Y.Z`` (for example
``11.0.1``), without a suffix or snapshot. The tag version must match the
root POM, parent POM, compiler parent version and CMake project version. The C
repository must contain the **exact same tag**. Tags with a ``v`` prefix are rejected.
Pull requests, branch pushes and manual workflow runs never publish.
Expand Down Expand Up @@ -261,23 +264,21 @@ One-time account and signing setup:

Keep the exported private key outside the checkout. Central needs the public
key to verify signatures; see https://central.sonatype.org/publish/requirements/gpg/.
#. In GitHub, open **Settings > Secrets and variables > Actions > New repository
secret** and add:

============================= ================================================
Secret Value
============================= ================================================
``MAVEN_CENTRAL_USERNAME`` Generated Central Portal token username
``MAVEN_CENTRAL_PASSWORD`` Generated Central Portal token password
``MAVEN_GPG_KEY`` Entire ASCII-armored exported private key
``MAVEN_GPG_PASSPHRASE`` Signing key passphrase
``MAVEN_GPG_KEY_FINGERPRINT`` Optional: fingerprint if exporting multiple keys
============================= ================================================

The signing plugin reads these environment variables directly using its Java
BC signer; no GPG executable or key import is required on the runner. Secrets
are supplied only to the tag publication step. No extra GitHub token permission
is required beyond the workflow's existing ``contents: read``.
#. Make the following GitHub organization Actions secrets available to this
repository (or configure repository secrets with the same names):

* ``CENTRAL_SONATYPE_TOKEN_USERNAME``: generated Central Portal token username.
* ``CENTRAL_SONATYPE_TOKEN_PASSWORD``: generated Central Portal token password.
* ``GPG_PRIVATE_KEY``: entire ASCII-armored exported private key.
* ``GPG_PASSPHRASE``: signing key passphrase.
* ``GPG_KEY_ID``: signing key ID or fingerprint.

The release job imports the private key through ``actions/setup-java``. Maven's
GPG signer selects ``GPG_KEY_ID`` and reads the passphrase from the
``MAVEN_GPG_PASSPHRASE`` environment variable. The Central token is mapped to the
``central`` server in ``.github/maven-settings.xml``. Secrets are used only in the
publication job, after the reusable build succeeds. No extra GitHub token
permission is required beyond ``contents: read``.

For example, after all versions are updated to ``11.0.1`` and the C repository
has ``11.0.1``, push the Java release tag:
Expand All @@ -287,13 +288,15 @@ has ``11.0.1``, push the Java release tag:
git tag -a 11.0.1 -m "Cyclone DDS Java 11.0.1"
git push origin 11.0.1

Local deployment dry run (requires a signing key in the environment, but no
Local deployment dry run (requires an imported GPG signing key and
``MAVEN_GPG_PASSPHRASE`` in the environment, but no
Central credentials and **does not upload**):

.. code-block:: sh

mvn --settings .github/maven-settings.xml -f maven/pom.xml \
-Prelease-artifacts,central-release -DskipUpload=true \
-Dgpg.keyname=YOUR_KEY_ID \
-Dcyclonedds.runtime.jar=/absolute/path/to/verified-runtime.jar \
-Dcyclonedds.idlc.verifiedJar=/absolute/path/to/verified-compiler.jar deploy

Expand Down
4 changes: 2 additions & 2 deletions maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
<build><plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>3.2.8</version>
<!-- The BC signer reads MAVEN_GPG_KEY and MAVEN_GPG_PASSPHRASE directly. -->
<configuration><signer>bc</signer><bestPractices>true</bestPractices></configuration>
<!-- GnuPG uses the imported key and reads MAVEN_GPG_PASSPHRASE directly. -->
<configuration><bestPractices>true</bestPractices></configuration>
<executions><execution><id>sign</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions>
</plugin>
<plugin>
Expand Down
Loading