gitsemver

command module
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 7 Imported by: 1

README

build coverage goreport Docs

gitsemver

Build a semver compliant version string for a git repository.

Using tree hashes it returns the latest matching semver tag. If no tree hash match exactly, it falls back to the latest semver tag reachable from the current HEAD.

If the match is not exact or the current branch is not the default branch or a protected branch, it creates a work-in-progress semver string like v0.1.2-myfeature.123.

Supports raw git repositories as well as GitLab and GitHub builders.

Print current version of a git repository

$ go install github.com/linkdata/gitsemver@latest
$ gitsemver $HOME/myreleasedpackage
v1.2.3

Generate a go package file with version information

//go:generate go run github.com/linkdata/gitsemver@latest -gopackage -out version.gen.go

Generates a file called version.gen.go with contents like

// Code generated by gitsemver at 2025-02-10 07:47:15 UTC DO NOT EDIT.
// branch "mybranch", build 456
package mypackage

const PkgName = "mypackage"
const PkgVersion = "v1.2.3-mybranch.456"

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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