Documentation
¶
Overview ¶
Package release — assets.go orchestrates cross-compilation for Go projects.
Package release — assetsbuild.go contains low-level build helpers for cross-compilation targets.
Package release — assetstargets.go defines the default cross-compile target matrix.
Package release — assetsupload.go uploads release assets via GitHub API.
Package release handles version parsing, release workflows, GitHub integration, and release metadata management.
Package release — checksums.go generates SHA256 checksums for release assets.
Package release — compress.go wraps release assets in archives. Windows assets → .zip, Linux/macOS assets → .tar.gz.
Package release — compresstar.go handles tar.gz archive creation.
Package release — deflate.go provides a max-compression Deflate writer.
Package release handles version parsing, release workflows, and release metadata management.
Package release — githubapi.go provides GitHub API types and helpers.
Package release handles version parsing, release workflows, GitHub integration, and release metadata management.
Package release — installsnippet.go appends a pinned-version installer snippet to the GitHub release body so users who copy the snippet from the release page install EXACTLY that tag, never auto-resolving "latest".
Spec: spec/04-release/08-pinned-version-install-snippet.md
Package release handles version parsing, release workflows, GitHub integration, and release metadata management.
Package release — remoteorigin.go parses git remote origin URLs.
Package release handles version parsing, release workflows, GitHub integration, and release metadata management.
Package release handles version parsing, release workflows, GitHub integration, and release metadata management.
Package release — workflowreleasescript.go bakes the version into copies of release-version.ps1 / release-version.sh and writes them into the staging directory so they ship as per-release snapshot install assets.
Spec: spec/01-app/105-release-version-script.md
Package release — ziparchive.go creates ZIP archives from zip groups with maximum compression (Deflate level 9) for release assets.
Index ¶
- func AppendPinnedInstallSnippet(body, tag string) string
- func BinaryName(moduleName string) string
- func BranchExists(branch string) bool
- func BuildAdHocArchive(paths []string, bundleName, stagingDir string) []string
- func BuildZipGroupArchives(db *store.DB, groupNames []string, stagingDir string) []string
- func CheckoutBranch(branch string) error
- func CleanupStagingDir()
- func CollectAssets(assetsPath string) []string
- func CollectSuccessfulBuilds(results []CrossCompileResult) []string
- func CommitExists(sha string) bool
- func CompressAssets(assets []string) ([]string, error)
- func CreateBranch(branchName, sourceRef string) error
- func CreateBranchFromSHA(branchName, sha string) error
- func CreateTag(tag, message string) error
- func CurrentBranchName() (string, error)
- func CurrentCommitSHA() (string, error)
- func DeleteLocalBranch(branch string) error
- func DeleteRemoteBranches(branches []string) error
- func DescribeCompression(assets []string) []string
- func DescribeTargets(binName, version string, targets []BuildTarget) []string
- func DetectChangelog() string
- func DetectGoProject() bool
- func DetectReadme() string
- func DryRunAdHoc(paths []string, bundleName string)
- func DryRunZipGroups(db *store.DB, groupNames []string)
- func EnsureGitignore()
- func EnsureStagingDir() (string, error)
- func Execute(opts Options) error
- func ExecuteFromBranch(branchName, assetsPath, notes string, isDraft, dryRun, noCommit, yes bool) error
- func ExecutePending(assetsPath, notes string, isDraft, dryRun, noCommit, yes bool) error
- func ExecuteSelf(opts Options) error
- func FetchBranch(branch string) error
- func FindMainPackages() []string
- func FormatChangelogSection(version string, commits []string) string
- func GenerateChangelog(fromTag, toRef string) ([]string, error)
- func GenerateChecksums(assets []string) (string, error)
- func IsInsideGitRepo() bool
- func ListTags() ([]string, error)
- func ListTempReleaseBranches() ([]string, error)
- func NormalizeVersion(version string) string
- func ParseGitURLExported(url string) (string, string, error)
- func ParseRemoteOrigin() (string, string, error)
- func PushBranchAndTag(branchName, tag string) error
- func PushBranches(branches []string) error
- func ReadModuleName() (string, error)
- func ReadVersionFile() (string, error)
- func ReleaseExists(version Version) bool
- func ResolveSourceRef(commit, branch string) (string, string, error)
- func ResolveTagRange(fromTag, toTag string) (string, string, error)
- func Rollback(branchName, tag, originalBranch string)
- func ShouldPrintInstallHint(remoteURL string) bool
- func TagExistsLocally(tag string) bool
- func TagExistsRemote(tag string) bool
- func UploadAllAssets(owner, repo string, releaseID int, assets []string, token string)
- func UploadAsset(owner, repo string, releaseID int, filePath, token string) error
- func WriteLatest(v Version) error
- func WriteReleaseMeta(meta ReleaseMeta) error
- type AutoCommitResult
- type BuildTarget
- type ChangelogBullet
- type ChangelogEntry
- type CrossCompileResult
- type GitHubRelease
- type LatestMeta
- type Options
- type ReleaseMeta
- type Result
- type TagEntry
- type TempReleaseCommit
- type Version
- type VersionFile
- type ZipGroupArchive
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendPinnedInstallSnippet ¶
AppendPinnedInstallSnippet returns the release body with a markdown section appended that contains PowerShell + bash one-liners pinned to the given tag. Idempotent: if the body already ends with a snippet for the same tag, it is returned unchanged.
func BinaryName ¶
BinaryName extracts the short name from a Go module path. "github.com/alimtvnetwork/gitmap-v19/gitmap" → "gitmap"
func BranchExists ¶
BranchExists checks if a local branch exists.
func BuildAdHocArchive ¶
BuildAdHocArchive creates a ZIP from ad-hoc paths provided via -Z flags. If bundleName is set, all items go into one archive; otherwise each gets its own archive.
func BuildZipGroupArchives ¶
BuildZipGroupArchives resolves persistent zip groups from the DB and creates max-compression ZIP archives for each. Returns archive paths.
func CheckoutBranch ¶
CheckoutBranch checks out an existing branch.
func CleanupStagingDir ¶
func CleanupStagingDir()
CleanupStagingDir removes the staging directory after upload.
func CollectAssets ¶
CollectAssets gathers file paths for release attachment.
func CollectSuccessfulBuilds ¶
func CollectSuccessfulBuilds(results []CrossCompileResult) []string
CollectSuccessfulBuilds filters cross-compile results to only successful outputs.
func CommitExists ¶
CommitExists checks if a commit SHA is valid.
func CompressAssets ¶
CompressAssets wraps each file in assets into an archive. Windows binaries (.exe) → .zip, others → .tar.gz. Returns the list of archive paths (originals are removed).
func CreateBranch ¶
CreateBranch creates a release branch from the given source ref.
func CreateBranchFromSHA ¶
CreateBranchFromSHA creates a branch at a specific commit without checkout.
func CurrentBranchName ¶
CurrentBranchName returns the current branch name.
func CurrentCommitSHA ¶
CurrentCommitSHA returns the full SHA of HEAD.
func DeleteLocalBranch ¶
DeleteLocalBranch deletes a local branch.
func DeleteRemoteBranches ¶
DeleteRemoteBranches deletes multiple branches from the remote.
func DescribeCompression ¶
DescribeCompression returns human-readable archive names for dry-run.
func DescribeTargets ¶
func DescribeTargets(binName, version string, targets []BuildTarget) []string
DescribeTargets returns human-readable names for dry-run output.
func DetectChangelog ¶
func DetectChangelog() string
DetectChangelog returns the content of CHANGELOG.md if it exists.
func DetectGoProject ¶
func DetectGoProject() bool
DetectGoProject checks if the current directory contains a buildable Go project.
func DetectReadme ¶
func DetectReadme() string
DetectReadme returns the path to README.md if it exists.
func DryRunAdHoc ¶
DryRunAdHoc prints what ad-hoc zip items would produce without creating them.
func DryRunZipGroups ¶
DryRunZipGroups prints what zip groups would produce without creating them.
func EnsureGitignore ¶
func EnsureGitignore()
EnsureGitignore appends missing release-related entries to .gitignore.
func EnsureStagingDir ¶
EnsureStagingDir creates the release-assets staging directory.
func ExecuteFromBranch ¶
func ExecuteFromBranch(branchName, assetsPath, notes string, isDraft, dryRun, noCommit, yes bool) error
ExecuteFromBranch runs the release workflow from an existing release branch.
func ExecutePending ¶
ExecutePending finds all release branches without tags and releases them. Also discovers unreleased versions from .gitmap/release/v*.json metadata files.
func ExecuteSelf ¶
ExecuteSelf resolves the gitmap source repo, switches to that directory, runs Execute, then returns to the original dir.
func FetchBranch ¶
FetchBranch fetches the latest of a remote branch.
func FindMainPackages ¶
func FindMainPackages() []string
FindMainPackages locates buildable main package directories. Checks root main.go first, then cmd/ subdirectories.
func FormatChangelogSection ¶
FormatChangelogSection formats commits as a markdown changelog section.
func GenerateChangelog ¶
GenerateChangelog returns commit subjects between two tags (or from a tag to HEAD).
func GenerateChecksums ¶
GenerateChecksums computes SHA256 hashes for all assets and writes a checksums.txt file in the same directory as the first asset. Returns the path to the checksums file.
func IsInsideGitRepo ¶
func IsInsideGitRepo() bool
IsInsideGitRepo checks if the current directory is inside a Git repository.
func ListTempReleaseBranches ¶
ListTempReleaseBranches returns all local branches matching temp-release/*.
func NormalizeVersion ¶
NormalizeVersion normalizes a changelog version string to v-prefixed form.
func ParseGitURLExported ¶
parseGitURL extracts owner/repo from HTTPS or SSH git URLs. ParseGitURLExported is the exported alias for testing.
func ParseRemoteOrigin ¶
ParseRemoteOrigin extracts owner/repo from the git remote origin URL.
func PushBranchAndTag ¶
PushBranchAndTag pushes the branch and tag to origin.
func PushBranches ¶
PushBranches pushes multiple branches to origin in a single command.
func ReadModuleName ¶
ReadModuleName reads the module name from go.mod.
func ReadVersionFile ¶
ReadVersionFile reads version.json from the project root.
func ReleaseExists ¶
ReleaseExists checks if a release metadata file already exists.
func ResolveSourceRef ¶
ResolveSourceRef returns the ref to use as the release base.
func ResolveTagRange ¶
ResolveTagRange determines the from/to refs based on user input.
func Rollback ¶
func Rollback(branchName, tag, originalBranch string)
Rollback deletes a local branch and tag after a failed push.
func ShouldPrintInstallHint ¶
ShouldPrintInstallHint returns true if the remote URL matches the gitmap source repository prefix.
func TagExistsLocally ¶
TagExistsLocally checks if a git tag exists in the local repo.
func TagExistsRemote ¶
TagExistsRemote checks if a git tag exists on the remote.
func UploadAllAssets ¶
UploadAllAssets uploads all assets to a GitHub release with exponential backoff retry.
func UploadAsset ¶
UploadAsset uploads a single file to a GitHub release.
func WriteLatest ¶
WriteLatest updates .gitmap/release/latest.json if the version is the highest stable.
func WriteReleaseMeta ¶
func WriteReleaseMeta(meta ReleaseMeta) error
WriteReleaseMeta writes release metadata to .gitmap/release/vX.Y.Z.json.
Types ¶
type AutoCommitResult ¶
AutoCommitResult describes what happened during auto-commit.
func AutoCommit ¶
func AutoCommit(version string, dryRun, yes bool) AutoCommitResult
AutoCommit inspects working tree changes after returning to the original branch. If only .gitmap/release/ files changed, it commits and pushes silently. If other files also changed, it prompts the user (or auto-confirms with yes=true). On decline, it commits only .gitmap/release/.
type BuildTarget ¶
BuildTarget represents a single GOOS/GOARCH pair for cross-compilation.
func DefaultTargets ¶
func DefaultTargets() []BuildTarget
DefaultTargets returns the standard 6-target cross-compilation matrix.
func ParseTargets ¶
func ParseTargets(input string) ([]BuildTarget, error)
ParseTargets parses a comma-separated "os/arch" string into BuildTargets. Example: "windows/amd64,linux/arm64"
func ResolveTargets ¶
func ResolveTargets(flagTargets string, configTargets []model.ReleaseTarget) ([]BuildTarget, error)
ResolveTargets determines the final target list using three-layer config: CLI flag (highest) → config.json release.targets (middle) → defaults (lowest).
type ChangelogBullet ¶
type ChangelogBullet struct {
Depth int
Ordered bool
Marker string // "-", "*", or "1." — preserved for ordered numbering
Text string
}
ChangelogBullet represents a single bullet line with its indent depth and whether it was an ordered-list item. Depth 0 = top-level, 1 = nested, etc.
type ChangelogEntry ¶
type ChangelogEntry struct {
Version string
Title string
Notes []string
Bullets []ChangelogBullet
}
ChangelogEntry represents one version section in CHANGELOG.md.
Notes is preserved for backward compatibility (flat top-level bullets). Title and Bullets are populated by the new structured parser used by the pretty-printed `changelog --latest` console output.
func FindChangelogEntry ¶
func FindChangelogEntry(entries []ChangelogEntry, version string) (ChangelogEntry, bool)
FindChangelogEntry returns a changelog entry by version.
func ReadChangelog ¶
func ReadChangelog() ([]ChangelogEntry, error)
ReadChangelog reads concise changelog entries from CHANGELOG.md.
type CrossCompileResult ¶
type CrossCompileResult struct {
Target BuildTarget
Output string
Success bool
Error string
}
CrossCompileResult holds the outcome of a cross-compile step.
func CrossCompile ¶
func CrossCompile(version string, targets []BuildTarget, packages []string, stagingDir string) []CrossCompileResult
CrossCompile builds binaries for all targets and packages. Returns the list of successfully built binary paths.
type GitHubRelease ¶
GitHubRelease represents the response from creating a GitHub release.
func CreateGitHubRelease ¶
func CreateGitHubRelease(owner, repo, tag, name, body, token string, draft bool) (*GitHubRelease, error)
CreateGitHubRelease creates a release via the GitHub API and returns the release ID.
type LatestMeta ¶
type LatestMeta struct {
Version string `json:"version"`
Tag string `json:"tag"`
Branch string `json:"branch"`
}
LatestMeta holds the pointer to the latest stable release.
func ReadLatest ¶
func ReadLatest() (LatestMeta, error)
ReadLatest reads .gitmap/release/latest.json.
type Options ¶
type Options struct {
Version string
Assets string
Commit string
Branch string
Bump string
Notes string
Targets string
ConfigTargets []model.ReleaseTarget
ZipGroups []string
ZipItems []string
BundleName string
IsDraft bool
DryRun bool
Verbose bool
Compress bool
Checksums bool
Bin bool
NoCommit bool
SkipMeta bool
Yes bool
}
Options holds all parameters for a release operation. v15: boolean fields use the IsX prefix convention.
type ReleaseMeta ¶
type ReleaseMeta struct {
Version string `json:"version"`
Branch string `json:"branch"`
SourceBranch string `json:"sourceBranch"`
Commit string `json:"commit"`
Tag string `json:"tag"`
Assets []string `json:"assets"`
Changelog []string `json:"changelog,omitempty"`
Notes string `json:"notes,omitempty"`
ZipGroups []string `json:"zipGroups,omitempty"`
ZipGroupChecksums map[string]string `json:"zipGroupChecksums,omitempty"`
IsDraft bool `json:"isDraft"`
IsPreRelease bool `json:"isPreRelease"`
CreatedAt string `json:"createdAt"`
IsLatest bool `json:"isLatest"`
}
ReleaseMeta holds metadata for a single release. v15: boolean fields use the IsX prefix convention. ReadReleaseMeta below adds backward-compat aliases so old "draft"/"preRelease" JSON files load without breakage; new files are written using the IsX form.
var LastMeta *ReleaseMeta
LastMeta holds the most recent release metadata after Execute completes.
func ListReleaseMetaFiles ¶
func ListReleaseMetaFiles() ([]ReleaseMeta, error)
ListReleaseMetaFiles reads all .gitmap/release/v*.json files and returns parsed metadata.
func ReadReleaseMeta ¶
func ReadReleaseMeta(path string) (ReleaseMeta, error)
ReadReleaseMeta reads and unmarshals a single .gitmap/release/vX.Y.Z.json file. Provides backward-compat for the pre-v15 "draft" / "preRelease" JSON keys by overlaying a legacy struct after the primary unmarshal.
type Result ¶
type Result struct {
Version Version
BranchName string
Tag string
Commit string
Source string
Assets []string
}
Result holds the outcome of a release operation.
type TagEntry ¶
TagEntry holds a parsed git tag name and its creation date.
func ListVersionTags ¶
func ListVersionTags() []TagEntry
ListVersionTags returns all semver tags with their creation dates.
type TempReleaseCommit ¶
TempReleaseCommit holds commit info for temp-release branch creation.
func ListRecentCommits ¶
func ListRecentCommits(count int) ([]TempReleaseCommit, error)
ListRecentCommits returns the last N commits from HEAD (oldest first).
type Version ¶
Version represents a parsed semantic version.
func Parse ¶
Parse parses a version string into a Version struct. Accepts formats: v1, v1.2, v1.2.3, v1.2.3-rc.1
func ResolveLatestVersion ¶
ResolveLatestVersion is the public, single source of truth for "what version is the repo currently pinned at?". Read order:
- .gitmap/release/latest.json — the canonical pin written by every successful release (see WriteLatest).
- Local git tags matching constants.GitTagGlob — the highest stable semver wins. Used for fresh clones / repos where the JSON has been deleted but the tag history is intact.
Returns the parsed Version on success, or an error describing which sources were tried. Used by:
- release.resolveBump (the `gitmap release --bump <level>` path)
- cmd.peekNextMinorVersion (the bare `gitmap release` auto-bump prompt + the right-click "Release next" context-menu entry)
- any future caller that needs the same source-of-truth ordering.
func (Version) CoreString ¶
CoreString returns the version without v prefix (e.g. 1.2.3).
func (Version) GreaterThan ¶
GreaterThan returns true if v is strictly greater than other.
func (Version) IsPreRelease ¶
IsPreRelease returns true if the version has a pre-release suffix.
type VersionFile ¶
type VersionFile struct {
Version string `json:"version"`
}
VersionFile represents the version.json file format.
type ZipGroupArchive ¶
ZipGroupArchive holds the result of archiving a zip group.
Source Files
¶
- assets.go
- assetsbuild.go
- assetstargets.go
- assetsupload.go
- autocommit.go
- autocommitgit.go
- changelog.go
- changeloggen.go
- changelogparse.go
- checksums.go
- compress.go
- compresstar.go
- deflate.go
- github.go
- githubapi.go
- gitignore.go
- gitops.go
- gitopsquery.go
- gitopstags.go
- gitstderrfilter.go
- httphelpers.go
- installsnippet.go
- metadata.go
- releaseinstallhint.go
- remoteorigin.go
- retry.go
- rollback.go
- selfrelease.go
- selfrelease_resolve.go
- semver.go
- temprelease.go
- workflow.go
- workflowbranch.go
- workflowdocs.go
- workflowdryrun.go
- workflowfinalize.go
- workflowgithub.go
- workflowpending.go
- workflowreleasescript.go
- workflowvalidate.go
- workflowzip.go
- ziparchive.go
- zipdryrun.go
- zipio.go