Documentation
¶
Overview ¶
Package changesets provides utilities for managing changesets and releases.
Index ¶
- Constants
- Variables
- func BuildReleaseSection(moduleKey, version, previousVersion, date string, changes []Change) string
- func BumpModule(moduleKey string, changes []Change) (string, error)
- func DeleteChangeFiles(changes []Change) error
- func GoModFor(module string) string
- func GroupByModule(changes []Change) map[string][]Change
- func MaxBump(changes []Change) string
- func MergeChangelog(existing, newSection string) string
- func NextVersion(current, bump string) (string, error)
- func ReadVersion(path string) (string, error)
- func TodayDate() string
- func UpdateModuleRequires() ([]string, error)
- func UpdateWorkspaceReplaces() (string, error)
- func WriteVersion(path, version string) error
- type Change
- type ModuleOption
- type ModulePaths
- type PublishConfig
Constants ¶
const ( DefaultDir = ".changesets" VersionFile = "VERSION" GoWorkFile = "go.work" ChangelogFile = "CHANGELOG.md" ChangelogHeader = "# CHANGELOG" BumpMajor = "major" BumpMinor = "minor" BumpPatch = "patch" ModuleCrypto = "crypto" ModuleEncoding = "encoding" )
Variables ¶
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 ¶
BuildReleaseSection generates the markdown block for one release.
func BumpModule ¶
BumpModule bumps the VERSION and updates the CHANGELOG for one module. It prints a summary line and returns the new version.
func DeleteChangeFiles ¶
DeleteChangeFiles removes the individual changeset .md files.
func GroupByModule ¶
GroupByModule splits a slice of changes into per-module buckets.
func MergeChangelog ¶
MergeChangelog inserts newSection after the "# CHANGELOG" header.
func NextVersion ¶
NextVersion applies the bump to a semver string "X.Y.Z".
func ReadVersion ¶
ReadVersion reads VERSION file from repo root
func UpdateModuleRequires ¶
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 ¶
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 ¶
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 ¶
LoadPending reads all .md files in .changesets (except those starting with "_") and parses their frontmatter + body into Change structs.
type ModuleOption ¶
ModuleOption represents a selectable module.
type ModulePaths ¶
ModulePaths resolves file paths for a given module. Pass "" for the root module.
func PathsFor ¶
func PathsFor(module string) ModulePaths
type PublishConfig ¶
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.