Repository navigation
Split the release workflow into a read-only build job and a release job - #26
Merged
Merged
Conversation
The release workflow ran as one job that checked out, built the plugin (Maven, npm and every package they pull in) and created the draft release, so all of it ran with a token that could write to the repository. On a GitHub-hosted runner any step can read the job's token. Now it is two jobs, as in diridium-com/oie-ssh-tunnel-manager#17: - build runs with contents: read and keeps the token out of .git/config. It checks the versions, builds and runs the tests (no more -DskipTests), fails if no test reports were produced, and uploads the zip and its .sha256 as an artifact with actions/upload-artifact v7.0.2 (cf430e03, 2026-10-07). - release (needs: build) holds contents: write and actions: read. It runs no checkout, no build tools and no action: gh downloads the artifact, checks it against its .sha256, refuses a tag whose release is already published, and creates the draft or replaces an existing draft's files. softprops/action-gh-release is no longer used. The published-release check moved from the start of the old job into the release job, so it now runs after the build. Nothing else about the release changes: the draft is still unsigned, a person still signs and publishes it, and the tag is still checked against every version file. RELEASING.md says so. Tested on a fork, pacmano1/oie-source-code-search, with immutable releases turned on and a throwaway version 0.0.1 tag on a commit whose only change from this one sets 0.0.1 in the six version files (run 40220314731): - Token permissions in the logs: build Contents read, Metadata read; release Actions read, Contents write, Metadata read. - The build job ran 14 tests (3 report files) and uploaded the zip; the release job's checksum check passed. - It created a draft: not a prerelease, title v0.0.1, the zip and its .sha256. The zip downloaded from the draft matches its .sha256, and its plugin.xml says 0.0.1 for OIE 4.7.0. - A re-run built a zip with different bytes and took the other path, "A draft exists for v0.0.1; replacing its files." The draft then held the new zip, which matches its new .sha256, so with immutable releases on a draft's files can still be replaced, which is how the signed zip goes onto the draft. Checked locally as well: the release job's two scripts, as written in the file, ran under bash -e against a stand-in gh in seven cases, all as expected, including the two the fork run didn't reach: an already published release fails with nothing created or uploaded, and any other gh error fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The release workflow ran as one job that checked out, built the plugin (Maven, npm and every package they pull in) and created the draft release, so all of it ran with a token that could write to the repository. On a GitHub-hosted runner any step can read the job's token.
It's now two jobs, as in diridium-com/oie-ssh-tunnel-manager#17:
contents: readand keeps the token out of.git/config. It checks the versions, builds and runs the tests (no more-DskipTests), fails if no test reports were produced, and uploads the zip and its.sha256as an artifact withactions/upload-artifactv7.0.2 (cf430e030ddbb5b0abf93d22962f4752f3646cd9, released 2026-10-07).needs: build) holdscontents: writeandactions: read. It runs no checkout, no build tools and no action.ghdownloads the artifact, checks it against its.sha256, refuses a tag whose release is already published, and creates the draft or replaces an existing draft's files.softprops/action-gh-releaseis no longer used.The published-release check moved from the start of the old job into the release job, so it now runs after the build. Nothing else about the release changes: the draft is still unsigned, a person still signs and publishes it, and the tag is still checked against every version file.
RELEASING.mdsays so.Tested on a fork,
pacmano1/oie-source-code-search, with immutable releases turned on and a throwaway version 0.0.1 tag on a commit whose only change from this branch sets 0.0.1 in the six version files:Contents: read,Metadata: read; releaseActions: read,Contents: write,Metadata: read.v0.0.1, the zip and its.sha256. The zip downloaded from the draft matches its.sha256, and itsplugin.xmlsays 0.0.1 for OIE 4.7.0..sha256. So with immutable releases on, a draft's files can still be replaced, which is how the signed zip goes onto the draft.Checked locally as well: the release job's two scripts, as written in the file, ran under
bash -eagainst a stand-inghin seven cases, all as expected. That includes the two the fork run didn't reach: an already published release fails with nothing created or uploaded, and any othergherror fails.Not run live: publishing a release, so the refusal of a published tag has only the stand-in test.
Co-authored with Claude Code.