From 3919e067decd14ddf2f3ec3b3a3da6a1715bd0ea Mon Sep 17 00:00:00 2001 From: Mark Shust Date: Sun, 5 Apr 2026 00:06:57 -0400 Subject: [PATCH] fix(release): derive repo from git remote for gh release create The release script's `gh release create` failed with "No default remote repository has been set" when `gh repo set-default` hadn't been run. Fix by deriving the repo from the origin remote URL and passing `--repo` explicitly. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/release.sh | 5 +++++ tests/ReleaseScriptTest.php | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/bin/release.sh b/bin/release.sh index 6652204..d88813d 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -48,6 +48,9 @@ else echo " ⚠ gh CLI not found — GitHub Release will need to be created manually" fi +# Derive repo from git remote so gh doesn't require set-default +GH_REPO=$(git remote get-url origin | sed -E 's#.*github\.com[:/](.+)\.git$#\1#; s#.*github\.com[:/](.+)$#\1#') + echo " ✓ PHP ${PHP_VERSION}" echo " ✓ Branch: main (merged from develop)" echo " ✓ Working directory clean" @@ -82,6 +85,7 @@ if [[ "$GH_AVAILABLE" == "true" ]]; then if [[ -n "$PREV_TAG" ]]; then if gh release create "$TAG" \ + --repo "$GH_REPO" \ --generate-notes \ --latest \ --notes-start-tag "$PREV_TAG"; then @@ -91,6 +95,7 @@ if [[ "$GH_AVAILABLE" == "true" ]]; then fi else if gh release create "$TAG" \ + --repo "$GH_REPO" \ --generate-notes \ --latest; then echo " ✓ GitHub Release created" diff --git a/tests/ReleaseScriptTest.php b/tests/ReleaseScriptTest.php index f8eef48..d6d4f2e 100644 --- a/tests/ReleaseScriptTest.php +++ b/tests/ReleaseScriptTest.php @@ -74,6 +74,13 @@ ->and($contents)->toContain('8.5'); }); +it('derives repo from git remote for gh release create', function () use ($script): void { + $contents = file_get_contents($script); + + expect($contents)->toContain('GH_REPO=$(git remote get-url origin') + ->and($contents)->toContain('--repo "$GH_REPO"'); +}); + it('creates bin/release.sh with version argument validation', function () use ($root, $script): void { expect(file_exists($script))->toBeTrue('bin/release.sh does not exist') ->and(is_executable($script))->toBeTrue('bin/release.sh is not executable');