Skip to content

Commit c0c9467

Browse files
Merge pull request #435 from SAP/add-central-release-workflow
Github Action to Build and Publish Releases
2 parents 807d5f6 + 32b2ef1 commit c0c9467

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/RELEASE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Release workflow
2+
3+
`release.yml` publishes to Maven Central (Sonatype Central Portal) via the `central` Maven profile. It runs on a published GitHub Release or a manual `workflow_dispatch`; it doesn't create releases.
4+
5+
## Flow
6+
1. Cut a GitHub Release (or dispatch the workflow, which won't create a github release).
7+
2. A maintainer approves the `maven-central` environment prompt.
8+
3. The job builds, signs, and uploads to the Portal, where it's staged.
9+
4. Someone with publish access in the Sonatype Portal (org membership on the `com.sap.hcp.cf.logging` namespace) publishes in the Portal to release to Central. This could be automated if deemed useful (https://central.sonatype.org/publish/publish-portal-maven/#autopublish).
10+
11+
## Secrets
12+
Kept on the `maven-central` GitHub Environment, not repo or org secrets. This is essential for security, if you ever need to set this up yourself (https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments):
13+
14+
- `MAVEN_CENTRAL_USERNAME` / `MAVEN_CENTRAL_PASSWORD`
15+
- `MAVEN_GPG_PRIVATE_KEY`
16+
- `MAVEN_GPG_PASSPHRASE`
17+
18+
They only inject after the environment rules pass: review, and allowed refs limited to `main`. Other runs are not able to retrieve the credentials.

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release to Maven Central
2+
3+
# Publishes to Maven Central (Sonatype Central Portal) via the `central` profile
4+
# in pom.xml. Uses signing/publishing secrets; see RELEASE.md before
5+
# changing triggers, permissions or the environment.
6+
7+
on:
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: release-maven-central
17+
cancel-in-progress: false
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 30
23+
environment: maven-central # secrets live here, gated by required reviewers
24+
steps:
25+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
26+
with:
27+
persist-credentials: false
28+
29+
- name: Set up JDK, Maven settings, GPG
30+
uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
31+
with:
32+
distribution: temurin
33+
java-version: '17'
34+
server-id: central
35+
# username/password/passphrase are env-var NAMES: setup-java writes them
36+
# into settings.xml and Maven resolves them from env at runtime (never on disk).
37+
# gpg-private-key is the actual key value: setup-java imports it here.
38+
server-username: MAVEN_CENTRAL_USERNAME
39+
server-password: MAVEN_CENTRAL_PASSWORD
40+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
41+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
42+
43+
- name: Deploy (uploads and stages; Publish is a manual click in the Portal)
44+
run: mvn -B -ntp -P central deploy
45+
env:
46+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
47+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
48+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

0 commit comments

Comments
 (0)