config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config defines typed configuration for releasegen and the helpers used to load it from environment variables and CLI flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCustomTypes

func ParseCustomTypes(raw string) (map[string]BumpType, error)

ParseCustomTypes parses a newline-separated list of "<heading>:<bump>" pairs into a canonical lower-case heading -> BumpType map.

func ParseExcludeDirs

func ParseExcludeDirs(raw string) []string

ParseExcludeDirs splits a newline- or comma-separated list of directories, trims whitespace, and normalizes each entry to end with "/".

Types

type BumpType

type BumpType uint8

BumpType is the SemVer increment classification for an unreleased section.

Values are ordered from least- to most-significant so callers can use numeric comparison ("if bump > current { current = bump }") to pick the highest-priority bump.

const (
	// BumpNone means no recognized change was detected.
	BumpNone BumpType = iota
	// BumpPatch corresponds to a SemVer patch increment.
	BumpPatch
	// BumpMinor corresponds to a SemVer minor increment.
	BumpMinor
	// BumpMajor corresponds to a SemVer major increment.
	BumpMajor
)

func ParseBumpType

func ParseBumpType(s string) (BumpType, error)

ParseBumpType parses a textual bump name (case-insensitive) into a BumpType.

func (BumpType) String

func (b BumpType) String() string

String returns the lower-case textual name of the bump type.

type Config

type Config struct {
	// Required GitHub Actions context.
	Token     string
	OwnerRepo string // "<owner>/<repo>"
	Actor     string
	Branch    string

	// Optional manual override.
	ManualVersion string
	Reason        string

	// Discovery / classification settings.
	ExcludeDirs []string
	CustomTypes map[string]BumpType // canonical lowercase heading -> bump

	// Operational flags.
	DryRun   bool // do not commit, push, tag, or publish
	Debug    bool // verbose tag/discovery diagnostics
	RepoRoot string

	// SummaryFile, if non-empty, receives a JSON summary of the run.
	SummaryFile string

	// SelfReleaseModule and SelfReleaseRepo together identify the
	// "releasegen releasing itself" case: when the module with this name is
	// released inside SelfReleaseRepo, the resulting version is printed to
	// stdout for downstream workflow steps to consume. SelfReleaseModule is
	// the module's directory path relative to the repo root; an empty value
	// means the root module (releasegen lives at the repository root). The
	// feature is active whenever SelfReleaseRepo is non-empty and matches
	// the repository being released; set SelfReleaseRepo to "" to disable.
	SelfReleaseModule string
	SelfReleaseRepo   string
}

Config is the fully resolved runtime configuration for a single releasegen invocation. All fields are populated from environment variables and/or CLI flags before the runner starts; nothing else in the codebase reads the process environment.

func FromEnv

func FromEnv() (*Config, error)

FromEnv builds a Config from process environment variables. It does not validate; callers should invoke Validate after applying any flag overrides.

func (*Config) Owner

func (c *Config) Owner() string

Owner returns the "owner" portion of OwnerRepo.

func (*Config) Repo

func (c *Config) Repo() string

Repo returns the "repo" portion of OwnerRepo.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that required fields are present and well-formed.

Jump to

Keyboard shortcuts

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