Skip to content

feat: publish agent releases via go-github instead of gh CLI (#457) - #462

Merged
antoinetoussaint-byte merged 3 commits into
mainfrom
issue-457-migrate-agent-release-publishing-from-gh-cli-to
Aug 23, 2026
Merged

feat: publish agent releases via go-github instead of gh CLI (#457)#462
antoinetoussaint-byte merged 3 commits into
mainfrom
issue-457-migrate-agent-release-publishing-from-gh-cli-to

Conversation

@antoinetoussaint-byte

@antoinetoussaint-byteantoinetoussaint-byte commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Closes#457.

Summary

  • Agent-release publishing shelled out to gh release create / gh release upload --clobber / gh release view for pure GitHub REST operations. These now go through the already-present github.com/google/go-github/v89 client, so the gh binary is no longer required on a release host when a token is available via env.
  • --clobber semantics are preserved: an existing same-named asset (archive and SBOM) is deleted before re-upload (the GitHub API rejects a duplicate asset name).
  • Client + token resolution — plus the publisher→owner mapping — is lifted into a small shared pkg/gh package so agent-release publishing and agent versions/list resolve credentials and repo owners one way. The gh auth token fallback stays, so local dev keeps working without exporting a token — gh is now a credential-only, optional dependency.

Genuine git operations (release tags via git tag/git push) are untouched, per the issue's out-of-scope note.

Behavior changes (intentional)

  • Release target repo is now derived, not discovered.gh resolved the repo from the working dir's origin remote; the new code computes owner/reg.GitHubRepository(name) — the same mapping verifyReleaseAssets and core's manager.DownloadURL (the install resolver) already use, pinned by TestLoaderArchiveName_MatchesInstallResolver. This is strictly more consistent (the old path could upload to origin then fail verification against the canonical URL), but publishing from a fork/mirror whose origin differs from the canonical owner/service-<name> repo now targets the canonical repo.
  • Preflight now requires a resolvable token, not the gh binary on PATH. A host with gh installed but logged out (or a token lacking contents:write) now fails fast at the validate phase with a clear "GitHub token is required" message instead of after the expensive CI run. Hosts that set GITHUB_TOKEN/GH_TOKEN or have an authenticated gh are unaffected.

Test plan

  • go build ./...
  • go vet ./cmd/publish/... ./cmd/agents/... ./pkg/gh/...
  • go test ./cmd/publish/... ./cmd/agents/... ./pkg/gh/...
  • pkg/gh tests cover token precedence (env over env, gh fallback, empty), authenticated/anonymous client construction, and the Owner publisher→owner mapping.
  • createAndUploadRelease tests (fake GitHub server) cover create-when-absent, the clobber path (delete-then-upload of a same-named asset), and the SBOM branch — both uploaded alongside the archive and both clobbered when pre-existing.

Note: make lint (golangci-lint) could not run locally — the installed golangci-lint is built with Go 1.26 while the repo targets 1.27; CI runs the real lint.

Replace the `gh release` subprocess in agent-release publishing with
go-github calls (GetReleaseByTag / CreateRelease / delete-then-upload
assets), so the `gh` binary is no longer required on release hosts when
a token is present. Lift the shared client/token plumbing into pkg/gh so
release publishing and version listing resolve credentials one way.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…upload (#457)
Address review findings on the go-github migration:
- The publisher→owner rule (dots→dashes) was copied in three places
(loaderDownloadURL, agentReleaser.afterPush, agents.githubSource). A
drift between any copy and core's manager.DownloadURL would silently
send an upload to a repo installers never read. Lift it to a single
gh.Owner so the release upload/verify path and the install resolver
can't diverge.
- The new release-upload tests never staged an SBOM, leaving the
asset.sbomPath branch (second per-asset upload + its clobber)
uncovered. Add tests that stage archive+SBOM and assert both upload,
and both are deleted-then-uploaded when pre-existing.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
golangci-lint govet flagged the releaser assignments in run/runReTag
for shadowing the outer err. Pre-declare releaser and assign with = so
the function-level err is reused.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@antoinetoussaint-byte
antoinetoussaint-byte merged commit 23e659c into mainAug 23, 2026
5 checks passed
@antoinetoussaint-byte
antoinetoussaint-byte deleted the issue-457-migrate-agent-release-publishing-from-gh-cli-to branch August 23, 2026 21:47
antoinetoussaint-byte added a commit that referenced this pull request Aug 23, 2026
Completes the go-github standardization for the platform (REST API)
operations that #457 (agent-release publishing, merged in #462) did not
cover, reconciled onto the shared pkg/gh helper that #462 introduced
rather than the separate pkg/github this work originally added:
- pkg/gitops/publish.go: promotion pull-request list/create/edit/verify
move from `gh pr *` to PullRequests.List/Create/Edit/Get.
- cmd/status/release.go: chore issue creation moves from `gh issue
create` to Issues.Create.
- pkg/librarystore/github.go: a first-ever library publish now creates
the target repo via Repositories.Get-then-Create when the clone fails,
instead of erroring; content publishing stays on git.
- pkg/gh: gains RepoAtDir/ParseRemote (owner/repo from the origin
remote) alongside the existing NewClient/Token/Owner.
Deliberately unchanged: pkg/gitops/observe.go still reads reviewDecision
through `gh` — a GraphQL-only field with no REST equivalent; deriving it
from REST review lists would weaken the promotion security gate. Git
content ops (clone/add/commit/tag/push) stay on the git binary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
antoinetoussaint-byte added a commit that referenced this pull request Aug 23, 2026
Completes the go-github standardization for the platform (REST API)
operations that #457 (agent-release publishing, merged in #462) did not
cover, reconciled onto the shared pkg/gh helper that #462 introduced
rather than the separate pkg/github this work originally added:
- pkg/gitops/publish.go: promotion pull-request list/create/edit/verify
move from `gh pr *` to PullRequests.List/Create/Edit/Get.
- cmd/status/release.go: chore issue creation moves from `gh issue
create` to Issues.Create.
- pkg/librarystore/github.go: a first-ever library publish now creates
the target repo via Repositories.Get-then-Create when the clone fails,
instead of erroring; content publishing stays on git.
- pkg/gh: gains RepoAtDir/ParseRemote (owner/repo from the origin
remote) alongside the existing NewClient/Token/Owner.
Deliberately unchanged: pkg/gitops/observe.go still reads reviewDecision
through `gh` — a GraphQL-only field with no REST equivalent; deriving it
from REST review lists would weaken the promotion security gate. Git
content ops (clone/add/commit/tag/push) stay on the git binary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto 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.

Migrate agent-release publishing from gh CLI to go-github API

1 participant

@antoinetoussaint-byte