release

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: EUPL-1.2 Imports: 19 Imported by: 0

Documentation

Overview

Package release provides release automation with changelog generation and publishing.

Package release provides release automation with changelog generation and publishing.

Package release provides release automation with changelog generation and publishing. It orchestrates the build system, changelog generation, and publishing to targets like GitHub Releases.

Package release provides release automation with changelog generation and publishing.

Package release provides release automation with changelog generation and publishing.

Index

Constants

View Source
const ConfigDir = ".core"

ConfigDir is the directory where release configuration is stored.

View Source
const ConfigFileName = "release.yaml"

ConfigFileName is the name of the release configuration file.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions compares two semver strings. Returns:

-1 if a < b
 0 if a == b
 1 if a > b

func ConfigExists

func ConfigExists(dir string) bool

ConfigExists checks if a release config file exists in the given directory.

func ConfigPath

func ConfigPath(dir string) string

ConfigPath returns the path to the release config file for a given directory.

func DetermineVersion

func DetermineVersion(dir string) (string, error)

DetermineVersion determines the version for a release. It checks in order:

  1. Git tag on HEAD
  2. Most recent tag + increment patch
  3. Default to v0.0.1 if no tags exist

func Generate

func Generate(dir, fromRef, toRef string) (string, error)

Generate generates a markdown changelog from git commits between two refs. If fromRef is empty, it uses the previous tag or initial commit. If toRef is empty, it uses HEAD.

func GenerateWithConfig

func GenerateWithConfig(dir, fromRef, toRef string, cfg *ChangelogConfig) (string, error)

GenerateWithConfig generates a changelog with filtering based on config.

func IncrementMajor

func IncrementMajor(current string) string

IncrementMajor increments the major version of a semver string. Examples:

  • "v1.2.3" -> "v2.0.0"
  • "1.2.3" -> "v2.0.0"

func IncrementMinor

func IncrementMinor(current string) string

IncrementMinor increments the minor version of a semver string. Examples:

  • "v1.2.3" -> "v1.3.0"
  • "1.2.3" -> "v1.3.0"

func IncrementVersion

func IncrementVersion(current string) string

IncrementVersion increments the patch version of a semver string. Examples:

  • "v1.2.3" -> "v1.2.4"
  • "1.2.3" -> "v1.2.4"
  • "v1.2.3-alpha" -> "v1.2.4" (strips prerelease)

func ParseCommitType

func ParseCommitType(subject string) string

ParseCommitType extracts the type from a conventional commit subject. Returns empty string if not a conventional commit.

func ParseVersion

func ParseVersion(version string) (int, int, int, string, string, error)

ParseVersion parses a semver string into its components. Returns (major, minor, patch, prerelease, build, error).

func ValidateVersion

func ValidateVersion(version string) bool

ValidateVersion checks if a string is a valid semver.

func WriteConfig

func WriteConfig(cfg *Config, dir string) error

WriteConfig writes the config to the .core/release.yaml file.

Types

type BuildConfig

type BuildConfig struct {
	// Targets defines the build targets.
	Targets []TargetConfig `yaml:"targets"`
}

BuildConfig holds build settings for releases.

type ChangelogConfig

type ChangelogConfig struct {
	// Include specifies commit types to include in the changelog.
	Include []string `yaml:"include"`
	// Exclude specifies commit types to exclude from the changelog.
	Exclude []string `yaml:"exclude"`
}

ChangelogConfig holds changelog generation settings.

type Config

type Config struct {
	// Version is the config file format version.
	Version int `yaml:"version"`
	// Project contains project metadata.
	Project ProjectConfig `yaml:"project"`
	// Build contains build settings for the release.
	Build BuildConfig `yaml:"build"`
	// Publishers defines where to publish the release.
	Publishers []PublisherConfig `yaml:"publishers"`
	// Changelog configures changelog generation.
	Changelog ChangelogConfig `yaml:"changelog"`
	// SDK configures SDK generation.
	SDK *SDKConfig `yaml:"sdk,omitempty"`
	// contains filtered or unexported fields
}

Config holds the complete release configuration loaded from .core/release.yaml.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns sensible defaults for release configuration.

func LoadConfig

func LoadConfig(dir string) (*Config, error)

LoadConfig loads release configuration from the .core/release.yaml file in the given directory. If the config file does not exist, it returns DefaultConfig(). Returns an error if the file exists but cannot be parsed.

func (*Config) GetProjectName

func (c *Config) GetProjectName() string

GetProjectName returns the project name from the config.

func (*Config) GetRepository

func (c *Config) GetRepository() string

GetRepository returns the repository from the config.

func (*Config) SetProjectDir

func (c *Config) SetProjectDir(dir string)

SetProjectDir sets the project directory on the config.

func (*Config) SetVersion

func (c *Config) SetVersion(version string)

SetVersion sets the version override on the config.

type ConventionalCommit

type ConventionalCommit struct {
	Type        string // feat, fix, etc.
	Scope       string // optional scope in parentheses
	Description string // commit description
	Hash        string // short commit hash
	Breaking    bool   // has breaking change indicator
}

ConventionalCommit represents a parsed conventional commit.

type OfficialConfig

type OfficialConfig struct {
	// Enabled determines whether to generate files for official repos.
	Enabled bool `yaml:"enabled"`
	// Output is the directory to write generated files.
	Output string `yaml:"output,omitempty"`
}

OfficialConfig holds configuration for generating files for official repo PRs.

type ProjectConfig

type ProjectConfig struct {
	// Name is the project name.
	Name string `yaml:"name"`
	// Repository is the GitHub repository in owner/repo format.
	Repository string `yaml:"repository"`
}

ProjectConfig holds project metadata for releases.

type PublisherConfig

type PublisherConfig struct {
	// Type is the publisher type (e.g., "github", "linuxkit", "docker").
	Type string `yaml:"type"`
	// Prerelease marks the release as a prerelease.
	Prerelease bool `yaml:"prerelease"`
	// Draft creates the release as a draft.
	Draft bool `yaml:"draft"`

	// LinuxKit-specific configuration
	// Config is the path to the LinuxKit YAML configuration file.
	Config string `yaml:"config,omitempty"`
	// Formats are the output formats to build (iso, raw, qcow2, vmdk).
	Formats []string `yaml:"formats,omitempty"`
	// Platforms are the target platforms (linux/amd64, linux/arm64).
	Platforms []string `yaml:"platforms,omitempty"`

	// Docker-specific configuration
	// Registry is the container registry (default: ghcr.io).
	Registry string `yaml:"registry,omitempty"`
	// Image is the image name in owner/repo format.
	Image string `yaml:"image,omitempty"`
	// Dockerfile is the path to the Dockerfile (default: Dockerfile).
	Dockerfile string `yaml:"dockerfile,omitempty"`
	// Tags are the image tags to apply.
	Tags []string `yaml:"tags,omitempty"`
	// BuildArgs are additional Docker build arguments.
	BuildArgs map[string]string `yaml:"build_args,omitempty"`

	// npm-specific configuration
	// Package is the npm package name (e.g., "@host-uk/core").
	Package string `yaml:"package,omitempty"`
	// Access is the npm access level: "public" or "restricted".
	Access string `yaml:"access,omitempty"`

	// Homebrew-specific configuration
	// Tap is the Homebrew tap repository (e.g., "host-uk/homebrew-tap").
	Tap string `yaml:"tap,omitempty"`
	// Formula is the formula name (defaults to project name).
	Formula string `yaml:"formula,omitempty"`

	// Scoop-specific configuration
	// Bucket is the Scoop bucket repository (e.g., "host-uk/scoop-bucket").
	Bucket string `yaml:"bucket,omitempty"`

	// AUR-specific configuration
	// Maintainer is the AUR package maintainer (e.g., "Name <email>").
	Maintainer string `yaml:"maintainer,omitempty"`

	// Chocolatey-specific configuration
	// Push determines whether to push to Chocolatey (false = generate only).
	Push bool `yaml:"push,omitempty"`

	// Official repo configuration (for Homebrew, Scoop)
	// When enabled, generates files for PR to official repos.
	Official *OfficialConfig `yaml:"official,omitempty"`
}

PublisherConfig holds configuration for a publisher.

type Release

type Release struct {
	// Version is the semantic version string (e.g., "v1.2.3").
	Version string
	// Artifacts are the built release artifacts (archives with checksums).
	Artifacts []build.Artifact
	// Changelog is the generated markdown changelog.
	Changelog string
	// ProjectDir is the root directory of the project.
	ProjectDir string
}

Release represents a release with its version, artifacts, and changelog.

func Publish

func Publish(ctx context.Context, cfg *Config, dryRun bool) (*Release, error)

Publish publishes pre-built artifacts from dist/ to configured targets. Use this after `core build` to separate build and publish concerns. If dryRun is true, it will show what would be done without actually publishing.

func Run

func Run(ctx context.Context, cfg *Config, dryRun bool) (*Release, error)

Run executes the full release process: determine version, build artifacts, generate changelog, and publish to configured targets. For separated concerns, prefer using `core build` then `core ci` (Publish). If dryRun is true, it will show what would be done without actually publishing.

type SDKConfig

type SDKConfig struct {
	// Spec is the path to the OpenAPI spec file.
	Spec string `yaml:"spec,omitempty"`
	// Languages to generate.
	Languages []string `yaml:"languages,omitempty"`
	// Output directory (default: sdk/).
	Output string `yaml:"output,omitempty"`
	// Package naming.
	Package SDKPackageConfig `yaml:"package,omitempty"`
	// Diff configuration.
	Diff SDKDiffConfig `yaml:"diff,omitempty"`
	// Publish configuration.
	Publish SDKPublishConfig `yaml:"publish,omitempty"`
}

SDKConfig holds SDK generation configuration.

type SDKDiffConfig

type SDKDiffConfig struct {
	Enabled        bool `yaml:"enabled,omitempty"`
	FailOnBreaking bool `yaml:"fail_on_breaking,omitempty"`
}

SDKDiffConfig holds diff configuration.

type SDKPackageConfig

type SDKPackageConfig struct {
	Name    string `yaml:"name,omitempty"`
	Version string `yaml:"version,omitempty"`
}

SDKPackageConfig holds package naming configuration.

type SDKPublishConfig

type SDKPublishConfig struct {
	Repo string `yaml:"repo,omitempty"`
	Path string `yaml:"path,omitempty"`
}

SDKPublishConfig holds monorepo publish configuration.

type SDKRelease

type SDKRelease struct {
	// Version is the SDK version.
	Version string
	// Languages that were generated.
	Languages []string
	// Output directory.
	Output string
}

SDKRelease holds the result of an SDK release.

func RunSDK

func RunSDK(ctx context.Context, cfg *Config, dryRun bool) (*SDKRelease, error)

RunSDK executes SDK-only release: diff check + generate. If dryRun is true, it shows what would be done without generating.

type TargetConfig

type TargetConfig struct {
	// OS is the target operating system (e.g., "linux", "darwin", "windows").
	OS string `yaml:"os"`
	// Arch is the target architecture (e.g., "amd64", "arm64").
	Arch string `yaml:"arch"`
}

TargetConfig defines a build target.

Directories

Path Synopsis
Package publishers provides release publishing implementations.
Package publishers provides release publishing implementations.

Jump to

Keyboard shortcuts

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