ci: implement automated releasing - #446
karel-rehor wants to merge 15 commits into
Conversation
* ci: start maven-release.yml workflow * chore: remove branches tag on release trigger * chore: add here doc for generating release.properties * chore: fix typo * chore: update pom.xml and deploy-settings.xml for fork. * chore: add simple volume check to workflow * chore: add release command to model release step * chore: reintroduce verify step to maven0release.yml workflow * docs: start RELEASE.md * docs: document gpg2 key generation in RELEASE.md. * chore: reintroduce checks in scripts/on-release.sh * docs: update temporary notes in CHANGELOG.md * chore: fix file permissions for on-release.sh * docs: temporary change to release date - for testing workflow. * docs: temporary update toe README.md to test workflow. * chore: set correct scm version an update RELEASE.md * chore: add scm/tag value check to on-release.sh * chore: fix dropped variable in on-release.sh * chore: temporarily change scm tag to test workflow failure. * chore: revert scm tag in pom.xml after workflow test proven correct. * chore: start workflow step Prepare next cycle. * chore: get correct TAG_NAME envar in workflow script. * chore: set next release cycle branch * chore: fix broken variable string in script. * chore: temporarily add debugging checks to workflow script. * chore: add automatic update to CHANGELOG.md in workflow. * chore: use correct envar in workflow script. * chore: fix formatting of next release CHANGELOG.md header * chore: setup automated git commands for next release cycle. * chore: setup github identity in release workflow prepare next cycle. * chore: fix push to origin in workstream Prepare next cycle. * chore: fix origin repository in workflow Prepare next release cycle. * chore: setup automatic PR for new release cycle. * chore: update permissions to allow creation of PR. * chore: remove automatic PR merge command - requires permission changes at org and project level to work. * chore: add site documentation update step. Update RELEASE.md * chore: add checks and updates to examples/pom.xml * chore: temporarily change examples dependency version to verify workflow. * chore: fix typo * chore: tidy maven-release.yml * chore: add check for remote next release branch. * docs: updated and proofed RELEASE.md * chore: clarify error message. * docs: add Maven Central step to releasing instructions. * chore: remove debug messages from on-release.sh * chore: remove debug messages from maven-release.yml * chore: troubleshoot document releasing step * chore: troubleshoot site publishing issue 02 * chore: troubleshoot site publishing - set to global. * chore: revert pubScmUrl - troubleshoot site publishing step. * chore: troubleshoot sit publishing 03 * chore: modify pubScmUrl to troubleshoot site publishing * chore: troubleshoot site publishing 05 * chore: revert troubleshoot changes * chore: troubleshoot site publishing 06 * chore: troubleshoot publish site documents. * chore: fix typo * chore: troubleshoot site document releasing 07 * chore: troubleshoot site documentation 08 * chore: troubleshoot publish sit documentation 09 * chore: troubleshoot publish sit documentation 10 * chore: troubleshoot publish sit documentation 11 * chore: troubleshoot publish sit documentation 12 * chore: troubleshoot publish sit documentation 13 * chore: troubleshoot publish sit documentation 14 * chore: troubleshoot publish sit documentation 15 * chore: troubleshoot publish sit documentation 16 * chore: troubleshoot publish sit documentation 17 * chore: troubleshoot publish sit documentation 18 * chore: remove debug commands from Publish documentation step. * chore: experim - try automatic PR creation. * chore: experim - try to create new PR 02 * chore: switch off automatic PR creation, requires special permissions. * chore: reactivate branch controls for prerelease. * chore: add env checks for matching scm values. * chore: fix path in script. * chore: remove debug of script ENV. * chore: remove commented nodes from pom.xml * docs: update RELEASE.md to match current workflow. * chore: remove unnecessary commands from workflow. * chore: prepare automated releasing branch for PR to upstream. * chore: remove experimental permissions from release workflow. * docs: update CHANGELOG.md * docs: lint fixes for RELEASE.md * docs: fix linting issues in RELEASE.md * docs: fixing lint issues in RELEASE.md 02 * docs: fix typos in RELEASE.md * chore: fixing lint issues in on-release.sh * chore: fix lint issues in maven-release.yml * chore: fix linter issue in maven-release.yml * chore: revise pom version values to match upstream HEAD. * docs: anonymize commands in RELEASE.md * chore: fix typo in on-releas.sh, add reminder to check RC_OR_BETA tagged releases. * chore: fix flaws in workflow and bash scripts. * chore: use more meaningful user.email in workflow. * chore: use current shell when calling on-release.sh in workflow * chore: fix RC or BETA release tag checks. * chore: update trigger, fix snapshot credentials, verify workfow envars. * chore: remove TODO and set RC_OR_BETA envar * chore: fix typos add TODOs for fixes in on-release.sh * chore: improve checks in on-release.sh * chore: better control sequencing, better checks in workflow. * chore: fine tune release workflow and script. * chore: remove snapshot checks, revert workflow check for next working snapshot branch. * chore: fine tune behavior for patch releases. * chore: update CHANGELOG.md, fix double negative and failure message. * chore: check gradle tag version in README.md * docs: clarify behavior of pre-release, beta/rc releases and patch releases in RELEASE.md. * chore: fix typo in ENVAR name and remove trim of release number. * chore: various updates to on-release.sh * chore: correct fix for on-release.sh * chore: script and doc tweaks. * chore: fix capitalization in user facing messages. * chore: fix capitalization in messages in workflow. * docs: add reminder about Gradle in RELEASE.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
=======================================
Coverage 88.73% 88.73%
=======================================
Files 21 21
Lines 1553 1553
Branches 281 281
=======================================
Hits 1378 1378
Misses 77 77
Partials 98 98 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bednar
left a comment
There was a problem hiding this comment.
Security review: changes are required before this PR can be approved.
| contents: write # may want to update version | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
There was a problem hiding this comment.
Security: Please run this job through a protected GitHub Actions environment named release, with required reviewers, self-review disabled, and deployment restricted to release tags matching v*. Move GPG_PRIVATE_KEY, GPG_PASSPHRASE, SONATYPE_USERNAME, and SONATYPE_PASSWORD to secrets of that environment.
Currently, the job receives all signing and publishing credentials immediately after a release is published and then executes the script and Maven configuration from the checked-out tag. A compromised or incorrectly created release tag could therefore exfiltrate these credentials before a second person reviews the release.
See GitHub documentation on environments, required reviewers, and branch/tag restrictions.
bednar
left a comment
There was a problem hiding this comment.
Security review: changes are required for the checkout and publishing authentication flow.
| GITHUB_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 |
There was a problem hiding this comment.
Security: Please set persist-credentials: false for this checkout. The default checkout behavior stores the contents: write token in .git/config while the release-tag script and Maven plugins are being executed. A compromised release tag or Maven plugin could read the token and push unauthorized changes to the repository.
Because this workflow later performs both git push and documentation publishing, authentication should be configured explicitly only in the steps that require it:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false- name: Prepare next cycle
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# ...
gh auth setup-git
git push --set-upstream origin "${NEXT_RELEASE_BRANCH}"For Maven documentation publishing, please add a token-free scm-settings.xml template:
<settings>
<servers>
<server>
<id>github</id>
<username>x-access-token</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>Then use it only in the publishing step:
- name: Build documentation
run: mvn clean site site:stage -DskipTests
- name: Publish documentation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -s ./scm-settings.xml --batch-mode \
scm-publish:publish-scm \
-Dscmpublish.serverId=githubPlease also remove GITHUB_TOKEN from the job-level environment. This keeps the token unavailable during the release build and documentation generation. Maven supports environment-variable interpolation in settings.xml; see the Maven Settings Reference and scm-publish authentication documentation.
bednar
left a comment
There was a problem hiding this comment.
Security review: the GPG passphrase must not be persisted across subsequent workflow steps.
| export GPG_PASSPHRASE="$GPG_PASSPHRASE_PRELIM" | ||
| fi | ||
|
|
||
| echo "GPG_PASSPHRASE=${GPG_PASSPHRASE}" >> "$GITHUB_ENV" |
There was a problem hiding this comment.
Please do not persist GPG_PASSPHRASE through $GITHUB_ENV. Set it only in the release/signing step, where it is required. Moving the secret to a protected environment controls when it becomes available, but $GITHUB_ENV still makes it available to every subsequent step in the job, including the next-cycle and documentation steps.
For example:
- name: Release
env:
GPG_PASSPHRASE_PRELIM: ${{ secrets.GPG_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
if [[ "$GPG_PASSPHRASE_PRELIM" == "EMPTY" ]]; then
GPG_PASSPHRASE=""
else
GPG_PASSPHRASE="$GPG_PASSPHRASE_PRELIM"
fi
export GPG_PASSPHRASE
mvn release:perform \
-Dgoals=deploy \
-s ./deploy-settings.xml \
-Darguments="-DskipTests -DskipITs -DperformRelease=true"Please remove the corresponding GPG_PASSPHRASE write to $GITHUB_ENV and keep the signing and Maven Central credentials scoped to this release step.
There was a problem hiding this comment.
sensitive secrets and environment variables no longer echoed into GITHUB_ENV
Proposed Changes
Sets up automated releasing.
nexus-staging-maven-pluginwith recommendedcentral-publishing-maven-pluginmaven-release.ymlon-release.shscript which ensures values inpom.xmlfiles and documentation match the release version and tag.pom.xml1.11.0 is incremented to 1.12.0-SNAPSHOT.Note this requires up-to-date values for action secrets (already configured in project - but not fully verified)
Checklist
[ ] A test has been added if appropriateN.A.