Skip to content

fix(release): strip refs/heads/ prefix from commit target - #38

Open
David Gamero (davidgamero) wants to merge 1 commit into
Azure:mainfrom
davidgamero:fix/normalize-release-commitish
Open

fix(release): strip refs/heads/ prefix from commit target#38
David Gamero (davidgamero) wants to merge 1 commit into
Azure:mainfrom
davidgamero:fix/normalize-release-commitish

Conversation

@davidgamero

Copy link
Copy Markdown
Collaborator

Complements #37.

What

create_release.yaml passes commit: refs/heads/${{ inputs.branch }} to ncipollo/release-action. That input expects a branch name or SHA, not a fully qualified ref. When release.yaml calls it with branch: ${{ github.ref }} (= refs/heads/main), the result is refs/heads/refs/heads/main — an invalid target_commitish that release-action v1.20.0 rejects with a 422 (seen in the v1.1.0 run).

This normalizes the input in the reusable workflow by stripping a leading refs/heads/, so callers may pass either a full ref or a short branch name.

Backwards compatibility (all 3 callers)

Caller branch in commit out
release.yaml refs/heads/main main
release_js_project.yaml releases/vX.Y.Z releases/vX.Y.Z (unchanged)
nightly_release.yaml releases/nightly releases/nightly (unchanged)

Only the refs/heads/… form is affected; short branch names pass through untouched. Input is passed via env to avoid shell injection.

Relationship to #37

#37 fixes release.yaml at the caller (github.refgithub.ref_name, plus v-prefixed tags). That's still needed and should land. This PR additionally hardens the shared create_release.yaml so it never emits a malformed commitish for any caller — relevant because the JS repos consume it via the mutable v1 tag. The two compose cleanly (this PR does not touch release.yaml).

create_release.yaml passed 'refs/heads/${{ inputs.branch }}' to
ncipollo/release-action's commit input, which expects a branch name or SHA,
not a fully qualified ref. When release.yaml passes github.ref
(refs/heads/main) this produced refs/heads/refs/heads/main, an invalid
target_commitish that release-action v1.20.0 rejects with a 422.

Normalize by stripping a leading refs/heads/ so callers may pass either a
full ref or a short branch name. Input passed via env to avoid injection.
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