headroom/.github/workflows
Tejas Chopra ac8646aa3c
fix(ci): scope the release credential and stop persisting it to disk (#3062)
## Description

`RELEASE_PLEASE_TOKEN` is currently a maintainer's personal PAT. It
bypasses branch and tag protection on `main` (`release-please.yml` says
so in its own comment), and forging a tag with it fires `release.yml`
and `docker.yml` on `release: published`, which publish to PyPI, npm and
GHCR. If it is a classic token with `repo` scope it is also valid
against every other repository that account can reach.

`release-metadata-sync.yml` made that credential readable on the runner.
`actions/checkout` defaults to `persist-credentials: true`, writing the
token into `.git/config`, and the very next step runs
`scripts/version-sync.py` **from the checked-out branch**. The trigger
is a push to the glob `release-please--branches--**`, which is not a
protected namespace, so a principal with push access could land a
modified `version-sync.py` and read it.

Closes #2955.

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Changes Made

- Both release workflows now prefer a GitHub App installation token —
scoped to this repository, expiring in an hour — over the PAT, via
`actions/create-github-app-token@v3`.
- The minting step is gated on `vars.RELEASE_APP_ID` and marked
`continue-on-error`, so an unconfigured app falls through to the
existing `PAT -> GITHUB_TOKEN` chain and nothing breaks today.
- `release-metadata-sync.yml`'s checkout no longer persists credentials,
and no longer receives a token at all.
- The final push supplies the credential through the step's own `env`
and an explicit remote URL, so it is never on disk while branch-supplied
code runs.

## Testing

- [x] Unit tests pass
- [x] Linting passes (ruff check + format on the test file)
- [ ] Type checking passes — N/A (YAML + test only)
- [x] New tests added for new functionality

### Test Output

```text
$ .venv/bin/python -m pytest tests/test_release_workflows.py -q
1 failed, 44 passed, 1 skipped in 0.23s
```

The single failure is `test_no_native_tls_in_wheel_build_tree`, which
shells out to `cargo`. It reproduces identically on unmodified `main` on
this machine (no Rust toolchain installed) and is unrelated to this
change.

New tests only:

```text
$ .venv/bin/python -m pytest tests/test_release_workflows.py -q -k "persist_credentials or scoped_app_token"
3 passed, 46 deselected in 0.18s
```

Against the parent commit:

```text
FAILED test_metadata_sync_does_not_persist_credentials_for_branch_supplied_code
FAILED test_release_workflows_prefer_scoped_app_token[release-please.yml-release-please]
FAILED test_release_workflows_prefer_scoped_app_token[release-metadata-sync.yml-sync]
3 failed, 46 deselected
```

## Real Behavior Proof

- Environment: macOS 15 (darwin 25.4.0), Python 3.12.13; workflows
parsed with PyYAML, not executed on a runner.
- Exact command / steps: parse both workflow files and assert (a) every
`actions/checkout` step sets `persist-credentials: false` and receives
no `token`, (b) exactly one gated `create-github-app-token` step exists
per workflow, and (c) every credential consumer places
`steps.app-token.outputs.token` ahead of `secrets.RELEASE_PLEASE_TOKEN`
in its fallback chain.
- Observed result: all three assertions pass on this branch and fail on
the parent commit. Both files remain valid YAML.
- **Not tested — important:** none of this has executed on a GitHub
runner. I have not minted a real installation token, not confirmed the
app-token step's `continue-on-error` fallback behaves as expected when
`vars.RELEASE_APP_ID` is unset, and not performed a real push with the
explicit-remote-URL form. The first live release run is the real test.

## Runtime Rollout Safety

- Rollout-managed feature(s): none.
- Minimum rollout channel: N/A.
- Stable/default behavior changed: no, unless `vars.RELEASE_APP_ID` is
set — without it both workflows resolve to exactly today's credential
chain.
- Kill switch / disable path: unset `vars.RELEASE_APP_ID` to fall back
to the PAT.
- Unsafe override required: none.
- Qualification impact: none.
- Rollback path: revert this commit.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective
- [x] New and existing unit tests pass locally with my changes

## Additional Notes

**This narrows blast radius; it does not make the trigger safe on its
own.** For an `on: push` workflow GitHub reads the workflow file from
the pushed ref, so a principal with push access can still edit this file
on their branch. The durable fix is the scoped app token *plus revoking
the personal PAT* — the revocation is a console action and is
deliberately not in this commit.

**Two repo settings are required to actually complete #2955**, and
neither can land in git:

```
vars.RELEASE_APP_ID              (repository variable)
secrets.RELEASE_APP_PRIVATE_KEY  (repository secret)
```

Until those exist this PR is a no-op on behavior and a defense-in-depth
improvement on the `persist-credentials` path only.

Co-authored-by: Tejas Chopra <tejas@Tejass-MacBook-Pro.local>
2026-08-16 19:05:32 -07:00
..
changelog-guard.yml ci(changelog): stop the CHANGELOG cascade — release-please owns it (#2329) 2026-07-16 14:28:57 -07:00
ci.yml fix: publish headroom-opencode in release workflow (#2372) 2026-08-11 23:56:40 -05:00
devcontainers.yml ci: bump actions/checkout from 4 to 7 (#1414) 2026-07-09 11:09:14 -05:00
docker.yml fix(ci): unjam release and Docker publishing (#2958) 2026-08-12 23:43:04 -05:00
docs.yml chore(docs): one documentation site, not two (#2784) 2026-08-04 16:42:49 -07:00
eval.yml feat(evals): weekly HotpotQA answer-recall report on the prose path (#1188) 2026-07-15 21:40:55 +00:00
init-e2e.yml ci: scope native/wheel/dashboard jobs to relevant paths (unstarve the queue) (#2155) 2026-07-13 23:50:26 -04:00
init-native-e2e.yml ci: bump actions/checkout from 4 to 7 (#1414) 2026-07-09 11:09:14 -05:00
install-native-e2e.yml ci: bump actions/checkout from 4 to 7 (#1414) 2026-07-09 11:09:14 -05:00
merge-conflicts.yml ci: concurrency-cancel Docker + Merge Conflicts to stop merge-spree pileups (#2138) 2026-07-13 13:47:59 -04:00
network-diff-capture.yml ci: require ONNX Runtime >= 1.24 and fail fast when it is missing or too old (#2591) 2026-07-27 08:04:53 -07:00
opencode-plugin.yml fix(opencode): ship the transport hook-shim so wheel installs route Node child traffic 2026-08-11 09:10:38 -07:00
pr-health.yml ci: preserve merge labels while state is unknown 2026-07-09 19:51:41 -05:00
publish.yml ci: bump actions/checkout from 4 to 7 (#1414) 2026-07-09 11:09:14 -05:00
release-metadata-sync.yml fix(ci): scope the release credential and stop persisting it to disk (#3062) 2026-08-16 19:05:32 -07:00
release-please.yml fix(ci): scope the release credential and stop persisting it to disk (#3062) 2026-08-16 19:05:32 -07:00
release.yml fix: publish headroom-opencode in release workflow (#2372) 2026-08-11 23:56:40 -05:00
rust.yml ci: require ONNX Runtime >= 1.24 and fail fast when it is missing or too old (#2591) 2026-07-27 08:04:53 -07:00
security.yml ci: bump actions/checkout from 4 to 7 (#1414) 2026-07-09 11:09:14 -05:00
stale.yml ci: bump actions/stale from 9 to 10 (#850) 2026-06-11 12:53:46 -05:00
wrap-e2e.yml fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
wrap-native-e2e.yml fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00