Documentation
¶
Overview ¶
Package ghup implements pubgh.AssetReplacer by invoking the gh CLI.
New builds a replacer that shells out to `gh release upload <tag> <path>... --repo <owner>/<name> --clobber` as an explicit argument slice. --clobber replaces an existing release asset of the same name. This adapter never deletes an asset it was not given: names outside the expected set are the caller's problem to refuse.
The App token is applied only as GH_TOKEN in the child environment. It is never placed on argv, stored in a formattable field, or included in returned errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Path is the gh executable. An empty path resolves "gh" from PATH
// with [exec.LookPath] when uploading.
Path string
// Dir is the child working directory. An empty Dir inherits the
// process working directory.
Dir string
// Token is the GitHub App token supplied as GH_TOKEN. It is revealed
// once when [New] constructs the replacer and is never stored on
// [Replacer].
Token rel.Secret
// Environ is the child process environment. A nil value inherits
// [os.Environ]. GH_TOKEN is always applied on top. The slice is
// used as-is and is never logged.
Environ []string
// Stderr receives gh diagnostics while the process runs. A nil
// value discards them. A nonzero exit still captures a bounded tail
// for the returned error.
Stderr io.Writer
}
Options configures a Replacer.
type Replacer ¶
type Replacer struct {
// contains filtered or unexported fields
}
Replacer invokes the gh CLI to clobber-upload release assets.
It implements pubgh.AssetReplacer. It performs no release creation, re-drafting, or deletion. Unexpected asset names must be refused by the caller before Replacer.Replace runs.
func New ¶
New constructs a Replacer from options.
Path resolution is deferred until Replacer.Replace so a missing binary is reported when uploading, not at construction. rel.Secret.Reveal is called once and the token is captured only inside the environment closure.
func (*Replacer) Replace ¶
func (r *Replacer) Replace( ctx context.Context, repository pubgh.Repository, tag rel.Tag, expected []pubgh.AssetPath, ) error
Replace implements pubgh.AssetReplacer.
It runs `gh release upload <tag> <path>... --repo <owner>/<name> --clobber` as an explicit argument slice through execx.Run, with the configured child working directory. --clobber replaces an existing asset of the same name. This method never deletes an asset it was not given. A nil context, a nil receiver, an empty tag, an empty repository, an empty asset list, or an empty path entry is rejected before any process starts. A nonzero exit returns an error that names the exit code and includes a bounded tail of stderr. The App token is supplied only as GH_TOKEN and never appears in argv or the error.