Skip to content

fix: use correct loop variable in attach-release-assets fallback - #45

Open
feafel wants to merge 1 commit into
circlefin:masterfrom
feafel:fix/attach-release-assets-trailing-newline
Open

feafel wants to merge 1 commit into
circlefin:masterfrom
feafel:fix/attach-release-assets-trailing-newline

Conversation

@feafel

@feafel feafel commented Oct 11, 2026

Copy link
Copy Markdown

Summary

Fixes #43: the reusable attach-release-assets.yaml workflow silently dropped the last glob-matched file when tj-actions/glob wrote its paths-output-file without a trailing newline.

The fallback variable was $p but the loop variable is $file. Since $p is unset, the no-trailing-newline fallback never fired.

Changes

  • .github/workflows/attach-release-assets.yaml: changed [ -n "$p" ] to [ -n "$file" ]

Impact

This workflow is reused across all Circle repositories, so the bug could affect release asset attachment in any of them.

🤖 Generated with Claude Code

The no-trailing-newline fallback used $p instead of $file, so the
last matched path was silently dropped when tj-actions/glob wrote
paths-output-file without a trailing newline.

Closes circlefin#43
zepeng811 pushed a commit that referenced this pull request Nov 12, 2026
## Summary

This repository holds 4 reusable workflows. Only `pr-scan.yaml` lets the
caller select a runner. The other 3 hardcode `runs-on: ubuntu-latest`.

This PR adds a `runs-on` input to those 3 workflows:

| Workflow | Job | Before | After |
| --- | --- | --- | --- |
| `attach-release-assets.yaml` | `release_attach_assets` |
`ubuntu-latest` | `${{ inputs.runs-on }}` |
| `actions-lint.yaml` | `lint_validate_actions` | `ubuntu-latest` | `${{
inputs.runs-on }}` |
| `conventional-commit-release.yaml` | `commit-lint` | `ubuntu-latest` |
`${{ inputs.runs-on }}` |
| `conventional-commit-release.yaml` | `release` | `ubuntu-latest` |
`${{ inputs.runs-on }}` |

Each new input copies the `runs-on` input that `pr-scan.yaml` already
defines. The description text, `required: false`, `type: string` and the
`ubuntu-latest` default all match that input.
`conventional-commit-release.yaml` applies one input to both of its
jobs.

`pr-scan.yaml` keeps its current content. This PR does not change it.

The default keeps the current behaviour, so no existing caller changes.

## Why this change is needed

A GitHub organization can enforce a runner policy. Such a policy can
forbid the GitHub-hosted `ubuntu-*` labels and allow only approved
runners. The policy then cancels any run that uses a forbidden label.

A policy of that kind reads every job in the caller workflow file. It
also reads the jobs of each reusable workflow that the caller starts. It
reads a job even when an `if` condition skips that job.

A hardcoded `runs-on` therefore breaks the caller in two ways:

1. The caller cannot select an approved runner for the reusable
workflow.
2. The caller loses its whole run, even when the affected job never
starts.

Point 2 is the harder one. A caller that starts
`attach-release-assets.yaml` only on a push to the default branch still
loses its pull request runs, because the policy reads the skipped job
too.

The same risk applies to `actions-lint.yaml` and
`conventional-commit-release.yaml`. This PR covers all 3 workflows
together, so no gap remains.

A caller-supplied `runs-on` also helps anyone who wants a larger runner
or a self-hosted runner for these workflows.

## Decision: this PR keeps the harden-runner step

PR #38 removes the `step-security/harden-runner` step and the `id-token:
write` permission from these workflows. That removal assumes the job
always runs on a custom runner that carries a built-in security agent.

That assumption holds only while `runs-on` stays hardcoded to such a
runner. Once `runs-on` becomes a caller input, the workflow cannot know
what the caller passes. A caller that passes `ubuntu-latest` would then
run with no runner-level agent and no workflow-level harden-runner.

I considered an `if:` condition that starts harden-runner only on a
runner without a built-in agent. I rejected that option for three
reasons:

1. The condition must match runner labels as strings. A caller may pass
a label, a runner group name, or a JSON array. A string match is
unreliable.
2. The condition must hold a list of approved labels. That list changes
over time, and this repository is public.
3. A fork of this repository has a different label set. The condition
gives the wrong result there.

This PR therefore keeps harden-runner for every runner.

Please confirm one point: the harden-runner action must support a runner
that already carries a security agent. I did not test that combination.

## Relationship to PR #38

I opened a separate PR instead of a rebase of #38. PR #38 changes the
same 4 files. Reasons:

- #38 is in a CONFLICTING state.
- The SHA pinning part of #38 is already on `master`. PR #39 and PR #41
pinned the actions to commit SHAs with version comments.
- The remaining content of #38 hardcodes one specific runner label and
removes harden-runner. This PR argues against both.
- A rebase of #38 must replace almost all of its content.

I excluded the SHA pinning from this PR, because `master` already has
it.

I did not close #38. Please decide what to do with it. I recommend that
you close it in favour of this PR.

## Open question for the repo owner: which default?

This PR uses `ubuntu-latest` as the default for all 3 inputs. That value
keeps the current behaviour and matches `pr-scan.yaml`. Please confirm
that choice or change it.

The trade-off:

- `ubuntu-latest` works for every consumer. Each consumer that needs
another runner must then pass one.
- A specific organization label is convenient for that one organization.
A consumer outside it cannot resolve the label. GitHub does not fail on
an unresolved label. The job queues until it times out.

This repository is public and has 14 forks. I could not determine if a
real external consumer exists. That answer decides the default.

## Required follow-up: the `v1` tag

A merge of this PR does not reach any consumer. Consumers use `@v1`.

The `v1` tag points to `057a20a7d108daaad3dc5e8e119cc2d53e42207c`, which
is release v1.3.5. The tags `v1`, `v1.3` and `stable` all still point to
that commit. `master` is 7 commits ahead, up to release v1.3.8.

The automatic tag move failed. The "Create additional tags" step of run
28533433898 failed with this error:

```
HttpError: Resource not accessible by integration - https://docs.github.com/rest/git/refs#create-a-reference
```

The release token appears to lack permission to write a git reference.

Two actions remain outside the scope of this PR:

1. Someone must repair the token permission for the "Create additional
tags" step.
2. Someone must move `v1`, `v1.3` and `stable` to a commit that contains
this change.

The `stable` tag matters too. The "Checkout Configs" step of
`pr-scan.yaml` checks out this repository at `ref: stable`.

I move no tag in this PR. Please tell me who owns that step.

## Testing

- I parsed all 5 workflow files with a YAML parser. Every file is valid.
- I confirmed that no job in `.github/workflows/` still hardcodes a
runner label.
- The pipeline of this repository calls the reusable workflows with no
`runs-on` value. The default keeps those calls working.
- This change does not touch PR #44 or PR #45. Those PRs change the
asset compile step of `attach-release-assets.yaml`.
- I opened this PR from a fork, because I have no write access. GitHub
therefore needs a maintainer to approve the workflow runs.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

attach-release-assets drops the last glob-matched file when the paths file has no trailing newline

2 participants