Skip to content

fix(ci): only release from pushes to this repo's main - #77

Merged
avelino merged 3 commits into
mainfrom
avelino/fix/release-workflow-run-guard
Oct 16, 2026
Merged

avelino merged 3 commits into
mainfrom
avelino/fix/release-workflow-run-guard

Conversation

@avelino

@avelino avelino commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

release.yml runs on workflow_run of CI, and CI runs on pull_request. The only gate was conclusion == success && head_branch == 'main', but head_branch is the branch name on the head repo. A fork PR from a branch called main passes that, so prepare hands the fork's head_sha to build, and release-latest (contents: write) deletes and republishes the latest pre-release with those binaries. install.sh falls back to releases/latest/download, so that's a real path to users. Fork approval is only required for first time contributors.

The gate now also requires workflow_run.event == 'push' and workflow_run.head_repository.full_name == github.repository:

CI run came from event head repo head_branch releases?
push to main here push avelino/jbundle main yes
PR from a branch here pull_request avelino/jbundle feature no (before: no)
PR from a fork's main pull_request fork main no (before: yes)
tag push here push avelino/jbundle v* no, the tag push trigger handles it

Same PR, smaller stuff: top level permissions: contents: read in ci.yml and release.yml (write stays only on release-latest and release-tag), every action pinned by commit SHA with the version in a comment (same majors, latest patch), .github/dependabot.yml for cargo and github-actions (weekly, grouped) so the pins don't rot, and a SECURITY.md. Private vulnerability reporting is off in the repo settings right now, I'll turn it on so the link in SECURITY.md works.

How it was tested

  • actionlint 1.7.12 with shellcheck off: clean. With shellcheck on: 12 info/style notes, the same 12 that main has today (none new).
  • Every uses: line is a 40 char SHA; each SHA was resolved from its tag with gh api repos/<action>/commits/<tag>.
  • CI on this PR runs the pinned actions for check, fmt, clippy, tests on 3 OSes and the examples.
  • First two CI runs had one e2e test fail on ubuntu (custom_exit_code once, hello_world_with_shrink once) with could not open .../rt-<hash>/lib/jvm.cfg; macOS and Windows were cancelled by fail-fast. The rerun passed on all three OSes. The Rust code here is identical to main, and main's Test job passed when rerun today, so it's a pre-existing flake: the stub skips extraction when $RT_DIR/bin exists, and when two binaries with the same runtime start at once the second can run java while the first is still untarring lib/. Separate fix, not in this PR.
  • Not tested yet: the release path itself. It only runs from a push to main, so the proof is the first push after merge still producing the latest pre-release. The fork case can't be reproduced without a fork named main, the truth table above is from the workflow_run payload fields.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documented private-reporting channel remains unavailable until the repository setting is enabled.

1 open finding
What changed in this PR

Secures releases against fork-originated CI runs and improves workflow supply-chain safety.

Changes:

  • Restricts releases to successful pushes from this repository’s main.
  • Pins Actions, limits token permissions, and adds Dependabot updates.
  • Adds a security policy and vulnerability-reporting guidance.
File Description
.github/​workflows/​release.yml Hardens release gating, permissions, and Action pins.
.github/​workflows/​ci.yml Restricts permissions and pins Actions.
.github/​dependabot.yml Automates Cargo and Action updates.
SECURITY.md Defines support, reporting, and scope.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread SECURITY.md Resolved
The release gate only checked that CI passed on a branch named main.
A pull request from a fork whose branch is also called main passes
that check, so its head would be built and published as the latest
pre-release. Require the CI run to come from a push in this repo.

Also set a read-only default token in both workflows, pin every
action by commit SHA, add Dependabot for cargo and actions, and add
a security policy.

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
@avelino
avelino force-pushed the avelino/fix/release-workflow-run-guard branch from 1e6d50d to 620b227 Compare October 16, 2026 11:03
@avelino
avelino merged commit f007876 into main Oct 16, 2026
15 of 17 checks passed
@avelino
avelino deleted the avelino/fix/release-workflow-run-guard branch October 16, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants