Skip to content

Name PR build artifacts after the branch, not a merge sha - #23

Merged
lepht merged 1 commit into
mainfrom
fix/ci-artifact-names
Aug 12, 2026
Merged

Name PR build artifacts after the branch, not a merge sha#23
lepht merged 1 commit into
mainfrom
fix/ci-artifact-names

Conversation

@lepht

@lepht lepht commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Independent of the feature stack — based on main so it can merge first and make the rest of the stack testable.

The problem

Actions checks a pull request out detached at a merge commit it invents, so git symbolic-ref finds nothing and BUILD_BRANCH (makefile:21) fell through to git rev-parse --short HEAD. Every PR artifact was named after a sha that exists on no branch and can't be found in local history.

Concretely, PR #1's build came out as:

NextUI-20260811-f4b9488-0-base.zip

f4b9488 is not the head of feat/favorites (0d0cb4e) — it's GitHub's synthetic merge commit. With six PRs open, that's six 105 MB downloads with interchangeable names and no way to tell them apart.

It works correctly on a push to main, which is presumably why it went unnoticed.

The fix

Take the branch from the environment when CI tells us what it is:

  • GITHUB_HEAD_REF — the source branch of a pull request.
  • GITHUB_REF_NAME — the branch of a push. On a pull request this is <number>/merge, which is why it can't be checked first.
  • Falls back to the previous symbolic-ref / rev-parse chain when neither is set, so local builds are unchanged.

Also widens the sanitiser from / to anything a filename shouldn't carry, since git permits a few more of those than it looks.

Verified

make name under each trigger:

case env result
pull request GITHUB_HEAD_REF=feat/favorites, GITHUB_REF_NAME=1/merge NextUI-20260812-feat-favorites-0
pull request GITHUB_HEAD_REF=fix/search-index-cap NextUI-20260812-fix-search-index-cap-0
push to main GITHUB_REF_NAME=main NextUI-20260812-0
push to branch GITHUB_REF_NAME=fix/atomic-writes NextUI-20260812-fix-atomic-writes-0
local none NextUI-20260812-fix-ci-artifact-names-0
awkward name GITHUB_HEAD_REF=feat/wip~2 odd NextUI-20260812-feat-wip-2-odd-0

A push to main still produces no branch suffix, so release naming does not move.

Getting it onto the open PRs

CI builds the merge commit, so a PR only picks this up once the fix is in its base branch:

Not fixed here

BUILD_HASH (makefile:20) has the same origin and still records the merge sha in version.txt. That one is arguably correct — it identifies the exact tree that was built — but it does mean the hash on a PR build won't match anything in your branch. Left alone rather than widened into this change.

Actions checks a pull request out detached at a merge commit it invents, so
git symbolic-ref finds nothing and BUILD_BRANCH fell through to rev-parse.
Every artifact from a PR was therefore named after a sha that exists on no
branch and cannot be found in local history - with several PRs open at once
they are a row of identically shaped names none of which say what they are.

Take the branch from the environment when CI tells us what it is.
GITHUB_HEAD_REF is the source branch of a pull request; GITHUB_REF_NAME is
the branch of a push, and on a pull request it is "<number>/merge", which is
why it cannot be checked first. Falls back to the old behaviour when neither
is set, so building locally is unchanged.

Also widens the sanitiser from slashes to anything a filename should not
carry, since git allows a few more of those than it looks.

A push to main still produces no branch suffix, so release names do not move.

  pull_request  GITHUB_HEAD_REF=feat/favorites  NextUI-20260812-feat-favorites-0
  push main     GITHUB_REF_NAME=main            NextUI-20260812-0
  local         (no CI env)                     NextUI-20260812-<branch>-0
@lepht
lepht merged commit 0902161 into main Aug 12, 2026
62 checks passed
@lepht
lepht deleted the fix/ci-artifact-names branch August 12, 2026 00:40
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.

1 participant