Skip to content

Commit ab4d78c

Browse files
committed
Clarify release GitHub App private key setup
1 parent b15d7f2 commit ab4d78c

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

.github/workflows/maven_central_release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,30 @@ jobs:
507507
fi
508508
done
509509
510+
- name: Validate release GitHub App private key
511+
env:
512+
RAW_PRIVATE_KEY: ${{ secrets.MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY }}
513+
run: |
514+
private_key="${RAW_PRIVATE_KEY//$'\r'/}"
515+
private_key="${private_key//\\n/$'\n'}"
516+
517+
if [[ "${private_key}" != *"-----BEGIN PRIVATE KEY-----"* && "${private_key}" != *"-----BEGIN RSA PRIVATE KEY-----"* ]]; then
518+
echo "::error::MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY must be the GitHub App private key PEM, including BEGIN/END lines. Do not use the app client secret or webhook secret."
519+
exit 1
520+
fi
521+
if ! printf '%s\n' "${private_key}" | openssl pkey -noout >/dev/null 2>&1; then
522+
echo "::error::MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY is present but is not a parseable PEM private key."
523+
exit 1
524+
fi
525+
510526
- name: Create release GitHub App token
511527
id: release-app-token
512528
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
513529
with:
514530
client-id: ${{ vars.MAVEN_RELEASE_GITHUB_APP_CLIENT_ID }}
515531
private-key: ${{ secrets.MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY }}
532+
owner: ${{ github.repository_owner }}
533+
repositories: ${{ github.event.repository.name }}
516534
permission-contents: write
517535

518536
- name: Check out release source

artifacts/release/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ actor** on the ruleset (Organization settings -> Rules -> `restrict-tag-pushing`
2222
Store the app credentials for the workflow:
2323

2424
- repository variable `MAVEN_RELEASE_GITHUB_APP_CLIENT_ID`: the app's client ID
25-
- `maven-release` environment secret `MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY`: a private key for the app
25+
- `maven-release` environment secret `MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY`: a GitHub App private key for the app,
26+
generated from the app's settings page
2627

2728
The branch ruleset on `main` is intentionally **not** bypassed. The next-development snapshot bump lands as an ordinary
2829
pull request, so `main` keeps its "PR-only, squash, one approval" protection.
2930

31+
`MAVEN_RELEASE_GITHUB_APP_PRIVATE_KEY` must be the PEM private key downloaded from the GitHub App's **Private keys**
32+
section, including the `BEGIN`/`END` lines. Do not use the app client secret or webhook secret. The workflow accepts the
33+
key pasted as a raw multi-line PEM or as a PEM with literal `\n` line separators; it validates the key before calling
34+
`actions/create-github-app-token` so setup failures point at the secret instead of surfacing as `Invalid keyData`.
35+
3036
The AWS secret referenced by `MAVEN_RELEASE_AWS_SECRET_ARN` must expose these JSON keys (they become environment
3137
variables of the same name): `MAVEN_GPG_PRIVATE_KEY`, `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD`, and
3238
optionally `MAVEN_GPG_PASSPHRASE` (omit or leave empty for a passphrase-less signing key).

0 commit comments

Comments
 (0)