release

package
v0.24.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BumpMajor = version.BumpMajor
	BumpMinor = version.BumpMinor
	BumpPatch = version.BumpPatch
	BumpNone  = version.BumpNone
)

Re-export version constants for backward compatibility

Variables

View Source
var (
	ParseVersion            = version.ParseVersion
	ZeroVersion             = version.ZeroVersion
	ComputeNextVersion      = version.ComputeNextVersion
	ParseConventionalCommit = version.ParseConventionalCommit
	FilterReleasableCommits = version.FilterReleasableCommits
	ExtractBreakingChanges  = version.ExtractBreakingChanges
	GroupCommitsByType      = version.GroupCommitsByType
	GetCommitTypeInfo       = version.GetCommitTypeInfo
)

Re-export version functions for backward compatibility

View Source
var (
	OpenRepository     = githelper.OpenRepository
	DiscoverLatestTag  = githelper.DiscoverLatestTag
	GetCommitsSinceTag = githelper.GetCommitsSinceTag
	GetRepositoryName  = githelper.GetRepositoryName
	ParseCommits       = githelper.ParseCommits
)

Re-export git helper functions for backward compatibility

View Source
var (
	GenerateChangelog        = changelog.GenerateChangelog
	GenerateChangelogPreview = changelog.GenerateChangelogPreview
	GenerateChangelogJSON    = changelog.GenerateChangelogJSON
	GetCommitStats           = changelog.GetCommitStats
)

Re-export changelog functions for backward compatibility

Functions

func ValidateMode

func ValidateMode(mode ReleaseMode) error

ValidateMode checks that a ReleaseMode string is one of the allowed values.

Types

type BumpType

type BumpType = version.BumpType

BumpType is an alias for version.BumpType for backward compatibility

type ChangelogGroupJSON

type ChangelogGroupJSON = changelog.GroupJSON

ChangelogGroupJSON is an alias for changelog.GroupJSON for backward compatibility

type ChangelogJSON

type ChangelogJSON = changelog.JSON

ChangelogJSON is an alias for changelog.JSON for backward compatibility

type ChangelogOptions

type ChangelogOptions = changelog.Options

ChangelogOptions is an alias for changelog.Options for backward compatibility

type CommitJSON

type CommitJSON = changelog.CommitJSON

CommitJSON is an alias for changelog.CommitJSON for backward compatibility

type CommitTypeInfo

type CommitTypeInfo = version.CommitTypeInfo

CommitTypeInfo is an alias for version.CommitTypeInfo for backward compatibility

type CutOptions

type CutOptions struct {
	RepoPath        string            // path to git repo (default ".")
	Branch          string            // expected branch (default "main")
	Remote          string            // git remote name (default "origin")
	PlanFile        string            // path to pre-generated plan JSON/YAML
	MutationsConfig string            // path to mutations config file
	DryRun          bool              // show what would happen without side effects
	Publish         bool              // create published release directly (no draft)
	Mode            ReleaseMode       // "auto" (default), "api", "local"
	CommitAuthor    string            // bot commit author name
	CommitEmail     string            // bot commit author email
	Token           string            // GitHub token for API and push
	ReleaseAPI      ReleaseService    // optional; created from Token if nil
	Assets          []string          // file paths to upload as release assets
	AssetLabels     map[string]string // optional asset name -> display label
}

CutOptions contains configuration for executing a release cut

func DefaultCutOptions

func DefaultCutOptions() *CutOptions

DefaultCutOptions returns options with sensible defaults

type CutResult

type CutResult struct {
	TagName        string   `json:"tag_name"`
	Version        string   `json:"version"`
	CommitSHA      string   `json:"commit_sha"`
	ReleaseURL     string   `json:"release_url,omitempty"`
	ReleaseID      int64    `json:"release_id,omitempty"`
	Draft          bool     `json:"draft"`
	Published      bool     `json:"published"`
	FilesModified  []string `json:"files_modified,omitempty"`
	UploadedAssets []string `json:"uploaded_assets,omitempty"`
	DryRun         bool     `json:"dry_run"`
	NoRelease      bool     `json:"no_release"`
	Reason         string   `json:"reason,omitempty"`
}

CutResult captures the outcome of a release cut

func ExecuteCut

func ExecuteCut(opts *CutOptions) (*CutResult, error)

ExecuteCut orchestrates the full release cut flow

func (*CutResult) ToJSON

func (r *CutResult) ToJSON() ([]byte, error)

ToJSON serializes the cut result to JSON

type FileMutation

type FileMutation struct {
	Path     string `json:"path" yaml:"path"`
	Type     string `json:"type" yaml:"type"`           // jsonPath, yamlPath, regex
	Field    string `json:"field" yaml:"field"`         // field being modified
	OldValue string `json:"old_value" yaml:"old_value"` // current value
	NewValue string `json:"new_value" yaml:"new_value"` // value after release
}

FileMutation represents a file change that would occur during release

type ParsedCommit

type ParsedCommit = version.ParsedCommit

ParsedCommit is an alias for version.ParsedCommit for backward compatibility.

type PlanOptions

type PlanOptions struct {
	// base ref to compare from (default: latest tag)
	FromRef string
	// target ref to compare to (default: HEAD)
	ToRef string
	// only follow first parent in merge commits
	FirstParent bool
	// path to repository (default: current directory)
	RepoPath string
	// output format (text, json, yaml)
	OutputFormat string
	// path to mutations config file (optional)
	MutationsConfig string
	// release mode: "auto" (default), "api", "local"
	Mode ReleaseMode
	// GitHub API client for API mode tag/commit discovery (optional)
	ReleaseAPI ReleaseService
	// branch name used as head for API compare (required for API mode)
	Branch string
}

PlanOptions contains options for generating a release plan

func DefaultPlanOptions

func DefaultPlanOptions() *PlanOptions

DefaultPlanOptions returns options with sensible defaults

type PublishOptions

type PublishOptions struct {
	RepoPath  string // path to git repo (for remote detection)
	Tag       string // specific tag to publish (mutually exclusive with Latest and ReleaseID)
	Latest    bool   // find latest draft (mutually exclusive with Tag and ReleaseID)
	ReleaseID int64  // publish by numeric release ID — works with GitHub App tokens
	// Note: --tag and --latest require a user token; GitHub App tokens cannot discover
	// draft releases via list/search endpoints. Use --release-id for App token workflows.
	Token      string         // GitHub token (required)
	DryRun     bool           // preview only, don't publish
	ReleaseAPI ReleaseService // optional; created from Token if nil
}

PublishOptions contains configuration for publishing a draft release

type PublishResult

type PublishResult struct {
	TagName    string `json:"tag_name"`
	ReleaseURL string `json:"release_url"`
	ReleaseID  int64  `json:"release_id"`
	Published  bool   `json:"published"` // always true on success
	DryRun     bool   `json:"dry_run"`
}

PublishResult captures the outcome of a release publish

func ExecutePublish

func ExecutePublish(opts *PublishOptions) (*PublishResult, error)

ExecutePublish orchestrates the full release publish flow

func (*PublishResult) ToJSON

func (r *PublishResult) ToJSON() ([]byte, error)

ToJSON serializes the publish result to JSON

type ReleaseMode

type ReleaseMode string

ReleaseMode controls how autogov performs git read operations

const (
	ModeAuto  ReleaseMode = "auto"  // use API if token present; fall back to local on error
	ModeAPI   ReleaseMode = "api"   // require GitHub API, fail hard on error
	ModeLocal ReleaseMode = "local" // use local go-git only (offline)
)

type ReleasePlan

type ReleasePlan struct {
	// metadata
	GeneratedAt time.Time `json:"generated_at" yaml:"generated_at"`
	Repository  string    `json:"repository" yaml:"repository"`

	// version info
	CurrentVersion string `json:"current_version" yaml:"current_version"`
	NextVersion    string `json:"next_version" yaml:"next_version"`
	BumpType       string `json:"bump_type" yaml:"bump_type"` // major/minor/patch/none

	// commits
	Commits         []ParsedCommit `json:"commits" yaml:"commits"`
	BreakingChanges []string       `json:"breaking_changes" yaml:"breaking_changes"`

	// changelog
	ChangelogPreview string `json:"changelog_preview" yaml:"changelog_preview"`

	// file mutations
	FileMutations []FileMutation `json:"file_mutations,omitempty" yaml:"file_mutations,omitempty"`

	// status
	ReleaseNeeded bool   `json:"release_needed" yaml:"release_needed"`
	Reason        string `json:"reason,omitempty" yaml:"reason,omitempty"`
}

ReleasePlan contains all information about a planned release

func GeneratePlan

func GeneratePlan(opts *PlanOptions) (*ReleasePlan, error)

GeneratePlan generates a complete release plan

func (*ReleasePlan) ToJSON

func (p *ReleasePlan) ToJSON() ([]byte, error)

ToJSON converts the plan to JSON format

func (*ReleasePlan) ToText

func (p *ReleasePlan) ToText() string

ToText converts the plan to human-readable text format

func (*ReleasePlan) ToYAML

func (p *ReleasePlan) ToYAML() ([]byte, error)

ToYAML converts the plan to YAML format

type ReleaseService

type ReleaseService interface {
	// release operations
	GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*gogithub.RepositoryRelease, *gogithub.Response, error)
	GetRelease(ctx context.Context, owner, repo string, id int64) (*gogithub.RepositoryRelease, *gogithub.Response, error)
	CreateRelease(ctx context.Context, owner, repo string, release *gogithub.RepositoryRelease) (*gogithub.RepositoryRelease, *gogithub.Response, error)
	UpdateRelease(ctx context.Context, owner, repo string, id int64, release *gogithub.RepositoryRelease) (*gogithub.RepositoryRelease, *gogithub.Response, error)
	ListReleases(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryRelease, *gogithub.Response, error)
	UploadReleaseAsset(ctx context.Context, owner, repo string, id int64, opts *gogithub.UploadOptions, file *os.File) (*gogithub.ReleaseAsset, *gogithub.Response, error)
	// read operations (tag discovery, commit comparison, branch validation)
	ListTags(ctx context.Context, owner, repo string, opts *gogithub.ListOptions) ([]*gogithub.RepositoryTag, *gogithub.Response, error)
	CompareCommits(ctx context.Context, owner, repo, base, head string, opts *gogithub.ListOptions) (*gogithub.CommitsComparison, *gogithub.Response, error)
	GetBranch(ctx context.Context, owner, repo, branch string, maxRedirects int) (*gogithub.Branch, *gogithub.Response, error)
	// git data operations (commits/tags created via API are auto-signed by GitHub per SLSA v1.2)
	CreateTree(ctx context.Context, owner, repo, baseTree string, entries []*gogithub.TreeEntry) (*gogithub.Tree, *gogithub.Response, error)
	CreateCommit(ctx context.Context, owner, repo string, commit gogithub.Commit, opts *gogithub.CreateCommitOptions) (*gogithub.Commit, *gogithub.Response, error)
	CreateTag(ctx context.Context, owner, repo string, tag gogithub.CreateTag) (*gogithub.Tag, *gogithub.Response, error)
	CreateRef(ctx context.Context, owner, repo string, ref gogithub.CreateRef) (*gogithub.Reference, *gogithub.Response, error)
	UpdateRef(ctx context.Context, owner, repo, ref string, updateRef gogithub.UpdateRef) (*gogithub.Reference, *gogithub.Response, error)
	DeleteRef(ctx context.Context, owner, repo, ref string) (*gogithub.Response, error)
}

ReleaseService abstracts GitHub API operations for testability

type Version

type Version = version.Version

Version is an alias for version.Version for backward compatibility

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL