changesets

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package changesets provides utilities for managing changesets and releases.

Index

Constants

View Source
const (
	DefaultDir      = ".changesets"
	VersionFile     = "VERSION"
	GoWorkFile      = "go.work"
	ChangelogFile   = "CHANGELOG.md"
	ChangelogHeader = "# CHANGELOG"

	BumpMajor = "major"
	BumpMinor = "minor"
	BumpPatch = "patch"

	ModuleCrypto   = "crypto"
	ModuleEncoding = "encoding"
)

Variables

View Source
var KnownModules = []ModuleOption{
	{Key: "", Label: "root (go-sdk)"},
	{Key: ModuleCrypto, Label: ModuleCrypto},
	{Key: ModuleEncoding, Label: ModuleEncoding},
}

KnownModules is the ordered list of modules in this repo.

Functions

func BuildReleaseSection

func BuildReleaseSection(moduleKey, version, previousVersion, date string, changes []Change) string

BuildReleaseSection generates the markdown block for one release.

func BumpModule

func BumpModule(moduleKey string, changes []Change) (string, error)

BumpModule bumps the VERSION and updates the CHANGELOG for one module. It prints a summary line and returns the new version.

func DeleteChangeFiles

func DeleteChangeFiles(changes []Change) error

DeleteChangeFiles removes the individual changeset .md files.

func GoModFor

func GoModFor(module string) string

GoModFor returns the go.mod path for a module key ("" = root).

func GroupByModule

func GroupByModule(changes []Change) map[string][]Change

GroupByModule splits a slice of changes into per-module buckets.

func MaxBump

func MaxBump(changes []Change) string

MaxBump returns the highest bump level across all changes.

func MergeChangelog

func MergeChangelog(existing, newSection string) string

MergeChangelog inserts newSection after the "# CHANGELOG" header.

func NextVersion

func NextVersion(current, bump string) (string, error)

NextVersion applies the bump to a semver string "X.Y.Z".

func ReadVersion

func ReadVersion(path string) (string, error)

ReadVersion reads VERSION file from repo root

func TodayDate

func TodayDate() string

TodayDate returns YYYY-MM-DD in local time.

func UpdateModuleRequires

func UpdateModuleRequires() ([]string, error)

UpdateModuleRequires rewrites the inter-module `require` directives in every module's go.mod so each points at the current VERSION of the module it depends on (crypto → encoding, root → crypto + encoding). This keeps the published module graph consistent with the VERSION files: without it the requires would keep the local-dev placeholder (v0.0.0, only resolvable via the go.work workspace / replace directives) and break for consumers. It returns the paths of the go.mod files it modified.

func UpdateWorkspaceReplaces

func UpdateWorkspaceReplaces() (string, error)

UpdateWorkspaceReplaces rewrites go.work's version-specific replace directives for nested modules to the current VERSION values. This lets release-branch CI build the release commit before those versions have been tagged publicly.

func WriteVersion

func WriteVersion(path, version string) error

Types

type Change

type Change struct {
	File   string `json:"file"`
	Module string `json:"module"` // "" means root; matches KnownModules Key
	Title  string `json:"title"`
	Bump   string `json:"bump"` // "patch" | "minor" | "major"
	Date   string `json:"date"` // "YYYY-MM-DD"
	Note   string `json:"note"` // full markdown body
}

Change represents one changeset entry.

func LoadPending

func LoadPending(dir string) ([]Change, error)

LoadPending reads all .md files in .changesets (except those starting with "_") and parses their frontmatter + body into Change structs.

type ModuleOption

type ModuleOption struct {
	Key   string // "" for root module
	Label string
}

ModuleOption represents a selectable module.

type ModulePaths

type ModulePaths struct {
	ChangesetDir  string
	VersionFile   string
	ChangelogFile string
}

ModulePaths resolves file paths for a given module. Pass "" for the root module.

func PathsFor

func PathsFor(module string) ModulePaths

type PublishConfig

type PublishConfig struct {
	TagPrefix  string
	ModulePath string
}

PublishConfig holds tag and module-path info for publishing a module.

func PublishConfigFor

func PublishConfigFor(module string) PublishConfig

PublishConfigFor returns the publish config for a given module key.

Jump to

Keyboard shortcuts

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