-
Notifications
You must be signed in to change notification settings - Fork 52
Github Action to Build and Publish Releases #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+66
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Release workflow | ||
|
|
||
| `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. | ||
|
|
||
| ## Flow | ||
| 1. Cut a GitHub Release (or dispatch the workflow, which won't create a github release). | ||
| 2. A maintainer approves the `maven-central` environment prompt. | ||
| 3. The job builds, signs, and uploads to the Portal, where it's staged. | ||
| 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). | ||
|
|
||
| ## Secrets | ||
| 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): | ||
|
|
||
| - `MAVEN_CENTRAL_USERNAME` / `MAVEN_CENTRAL_PASSWORD` | ||
| - `MAVEN_GPG_PRIVATE_KEY` | ||
| - `MAVEN_GPG_PASSPHRASE` | ||
|
|
||
| They only inject after the environment rules pass: review, and allowed refs limited to `main`. Other runs are not able to retrieve the credentials. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Release to Maven Central | ||
|
|
||
| # Publishes to Maven Central (Sonatype Central Portal) via the `central` profile | ||
| # in pom.xml. Uses signing/publishing secrets; see RELEASE.md before | ||
| # changing triggers, permissions or the environment. | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: release-maven-central | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| environment: maven-central # secrets live here, gated by required reviewers | ||
| steps: | ||
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up JDK, Maven settings, GPG | ||
| uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 | ||
| with: | ||
| distribution: temurin | ||
| java-version: '17' | ||
| server-id: central | ||
| # username/password/passphrase are env-var NAMES: setup-java writes them | ||
| # into settings.xml and Maven resolves them from env at runtime (never on disk). | ||
| # gpg-private-key is the actual key value: setup-java imports it here. | ||
| server-username: MAVEN_CENTRAL_USERNAME | ||
| server-password: MAVEN_CENTRAL_PASSWORD | ||
| gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | ||
| gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
|
||
| - name: Deploy (uploads and stages; Publish is a manual click in the Portal) | ||
| run: mvn -B -ntp -P central deploy | ||
| env: | ||
| MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | ||
| MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | ||
| MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KarstenSchnitter technically it makes no difference, but I would favor a sapmachine here . FYI @Felix-Griesau-SAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I have built the releases using a SAPMachine. I support the recommendation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open another PR for that.
I based the choice on the existing configuration in the other workflow though. I'll change that as well then:
cf-java-logging-support/.github/workflows/maven-verify.yml
Line 22 in d9413b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#441