import "github.com/egdaemon/eg/runtime/x/wasi/eggithub"
func DebugToken(ctx context.Context, o eg.Op) error
DebugToken logs what gh reports about the token the eggithub operations use: the account, where the token comes from, its kind and scopes. a debugging aid, it never fails, the token itself is not shown.
func DownloadURL(pattern string) string
generate the github download url
func Draft(patterns ...string) eg.OpFn
Draft creates (or reuses) a draft release for PatternVersion and uploads the given patterns to it. Does not verify or publish the release — pair with Promote to publish once all expected assets have been uploaded. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func DraftClean(ttl time.Duration) eg.OpFn
DraftClean deletes the draft releases that are older than ttl, drafts left behind by releases that failed or were abandoned before Promote. recent drafts, including the one in progress, are kept. a ttl of zero or less is a day. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func Env() []string
Env returns the environment entries (KEY=VALUE) needed for gh to authenticate, currently GH_TOKEN sourced from the GitHub token eg provides. pass them to a shell command's EnvironFrom:
gh := shell.Env().EnvironFrom(eggithub.Env()...)
shell.Run(ctx, gh.New("gh workflow run release.yml --ref main").Attempts(3))
for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func PatternVersion() string
provides the version pattern based on a github commit. provides sequentially incrementing versions based on the commit dates. assuming you're generating commits on merge this will always move forward.
func Promote(patterns ...string) eg.OpFn
Promote a draft release to a full release, this is very experimental. uses PatternVersion to determine which draft release to promote, and verifies that every pattern is already present in the release's asset listing before publishing it. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func PullRequest(c eggit.Changer, options ...pullrequestopts) eg.OpFn
PullRequest opens a pull request from the branch checked out in the change's worktree, see eggit.Change. the branch must be pushed first, see eggit.Push. nothing is done when there is no branch, i.e.) there was nothing to commit, or when the branch already has an open pull request. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func Release(patterns ...string) eg.OpFn
Release to github, this is very experimental. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func ReleaseClean(keep int) eg.OpFn
ReleaseClean deletes the published releases beyond the keep newest, the counterpart to DraftClean which handles drafts. drafts are never touched or counted, and the git tags of deleted releases are kept. a keep of zero or less is ten. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh.
func Upload(release string, patterns ...string) eg.OpFn
Upload an asset to a github release, this is very experimental. uploads into whatever release currently exists for the given version (typically a draft created by Draft), and does not publish it. for local environments `eg compute local` auto-detects a GitHub token via `gh auth token` when the repository's remote is github.com and the gh cli is installed. override it explicitly with e.g.) eg compute local -e GH_TOKEN=<token>, needed for environments without gh. Usage:
eggithub.Upload(eggithub.PatternVersion(), "foo.txt", "bar.txt")
func UploadRuntime(rt shell.Command, release string, patterns ...string) eg.OpFn