Files
headroom/.github/workflows/publish.yml
2973ca593d ci: pin every GitHub Action to a commit SHA (#4671)
## Description

Every third-party action in `.github/` ran from a version tag like
`actions/checkout@v7`. A tag can be moved to other code at any time.
That is how `tj-actions/changed-files` leaked CI secrets from ~23,000
repos in March 2025.

Here a moved tag would run with the release job's PyPI OIDC token
(`id-token: write`) and the Docker job's `packages: write` token.
Pinning to a commit SHA closes that, and a new test keeps it closed.

Closes #

## Type of Change

- [ ] 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
- [ ] Performance improvement
- [x] Code refactoring (no functional changes)

## Changes Made

- All 195 third-party `uses:` refs in 25 files now name the commit their
tag points to today, with the version as a comment:
`actions/checkout@3d3c42e5... # v7.0.1`. No action version changes.
- Dependabot's existing `github-actions` config updates SHA pins and
their version comments, so the pins stay current.
- Pin dtolnay/rust-toolchain stable and 1.95.0 branches to their
existing commit heads. The stable action retains its runtime toolchain
input/default; the 1.95.0 action embeds toolchain: 1.95.0. This
preserves each call site's existing toolchain selection.
- New `test_every_action_is_pinned_to_a_commit_sha` in
`scripts/tests/test_ci_workflow.py` fails on any tag-pinned action and
lists each one.
- Three tests in `tests/test_release_workflows.py` matched the old tag
text (`setup-buildx-action@v4`, `gh-action-pypi-publish@vX.Y.Z`,
`release-please-action@v4/v5`). They now match the SHA pin and its
version comment.

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
$ uv run --frozen --extra dev pytest -q scripts/tests/test_ci_workflow.py scripts/tests/test_pr_health_workflow.py scripts/tests/test_normalize_release_pr_bodies.py tests/test_release_workflows.py
87 passed in 0.87s

$ uv run --frozen --extra dev pytest -q scripts/tests/test_pr_health_labels.py scripts/tests/test_version_sync.py tests/test_cli/test_wrap_copilot.py tests/test_learn/test_subagent_scanning.py tests/test_plugin_manifests.py tests/test_pr208_changes.py
114 passed in 1.32s

$ uvx ruff check scripts/tests/test_ci_workflow.py tests/test_release_workflows.py && uvx ruff format --check <same>
All checks passed!
```

## Real Behavior Proof

- Environment: macOS, Python 3.12 via `uv run --frozen --extra dev`,
branch cut from `main` at c01cf07d.
- Exact command / steps: resolved each tag with `git ls-remote --tags
--heads https://github.com/<owner>/<repo>` (peeled for annotated tags),
rewrote only the `uses:` lines, then ran the test files above and a
`yaml.safe_load` over every file in `.github/`.
- Observed result: 195 lines changed, 195 removed, no other line touched
(mixed LF/CRLF in `pr-health.yml` kept). All 201 tests pass. On `main`
the new test fails and lists the unpinned refs.
- Not tested: `scripts/validate-workflows.sh` (actionlint plus act dry
runs) was not run locally. The `workflow-validation` job runs it on this
PR.

## Runtime Rollout Safety

- Rollout-managed feature(s): None. CI workflow files and their tests
only.
- Minimum rollout channel: N/A, no runtime code changes.
- Stable/default behavior changed: No. Each SHA is the commit its tag
points to today.
- Kill switch / disable path: N/A, revert the commit.
- Unsafe override required: No.
- Qualification impact: None.
- Rollback path: Revert this PR.

## 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
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Screenshots (if applicable)

N/A, no UI change.

## Additional Notes

- mypy and docs are N/A: no `headroom/` code or documented behavior
changes.
- Dependabot does not bump branch pins, so the two
`dtolnay/rust-toolchain` pins stay on today's branch head until someone
moves them. That action rarely changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/4671"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

### Maintainer current-main requalification

Exact head `57b7edd8d05b6dc5e3bc4eac1dff55f21519afe8`, upstream main
`c01cf07d943d816cfd9d97e6838ed4e38f1ff9a4`.

Reviewed the27-file delta and existing discussion/Devin no-issues result
against current upstream main c01cf07d94,
already included in the contributor head. Independent full-workflow
comparison proves only uses refs/comments change across the25
workflow/action files. All195 replaced refs resolve exactly to their
original upstream tag/branch commits (29 unique pins across26
repositories), with annotated tags peeled; no mismatches. Pinned dtolnay
action source independently confirms stable runtime default versus
embedded1.95.0 branch behavior, preserving toolchain selection.87
workflow/release tests and113 adjacent tests pass,1skip; changed Python
lint/format passes. Maintainer fix only removes CRLF endings on two
edited pr-health lines to clear whitespace; provenance reverified
afterward. No contributor workflow logic altered. Description is
corrected to explain embedded1.95.0 semantics. No publish/release
workflow execution claimed; full hosted qualification must run on this
new mechanical-fix head. Maintainers handle CI. Nothing merged.


Exact-head hosted checks are being handled by maintainers. No new
finding in the reviewed scope; formal approval awaits exact-head hosted
qualification; nothing merged.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
2026-11-06 09:16:15 -06:00

60 lines
2.0 KiB
YAML

name: Publish to PyPI (manual fallback)
# DEPRECATED: This workflow is superseded by release.yml's matrix-based
# build-and-publish flow. It exists as a manual fallback in case release.yml
# is broken and a hotfix needs to be pushed without going through the
# normal tag-driven pipeline. Single-platform; produces only the linux
# x86_64 wheel + sdist. For full cross-platform release, use release.yml.
on:
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # For trusted publishing
contents: write # For uploading release assets
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.11"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
toolchain: 1.95.0 # Keep in sync with rust-toolchain.toml.
- name: Cache cargo registry + build
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: ". -> target"
- name: Install build tools
run: |
python -m pip install --upgrade pip 'maturin>=1.5,<2.0' cyclonedx-bom
- name: Build wheel + sdist
run: |
maturin sdist --out dist
maturin build --release --out dist
- name: Generate SBOM (CycloneDX)
run: |
pip install -e ".[proxy]"
cyclonedx-py environment \
--output-format json \
--outfile dist/headroom-sbom.cdx.json
- name: Upload SBOM to release
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
files: dist/headroom-sbom.cdx.json
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3