relic

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: Apache-2.0 Imports: 6 Imported by: 20

README

Relic

Relic is a small library to help with versioning your projects by storing release metadata and versions as code.

Purpose

Relic allows you define your project version history in a declarative style by defining a History object somewhere in your project whose methods allow you to add releases defined by a version and release notes. It ensures you releases form a valid monotonic progression of semantic version compliant tagged releases.

From this is can generate the current version and a complete changelog using this information.

Usage


See Relic's own project package and Makefile for example usage within a project.

Dependencies

Go standard libary and tooling plus Make and Bash for builds (but not required)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultChangelogTemplate = template.Must(template.New("changelog_template").
	Parse(`# {{ .ProjectName }} Changelog{{ range .Releases }}
## Version {{ .Version }}
{{ .Notes }}
{{ end }}`))

Functions

func EnsureReleasesUniqueValidAndMonotonic

func EnsureReleasesUniqueValidAndMonotonic(rs []Release) error

Checks that a sequence of releases are monotonically decreasing with each version being a simple major, minor, or patch bump of its successor in the slice

Types

type History

type History struct {
	ProjectName       string
	Releases          []Release
	ChangelogTemplate *template.Template
}

The purpose of History is to capture version changes and change logs in a single location and use that data to generate releases and print changes to the command line to automate releases and provide a single source of truth for improved certainty around versions and releases

func NewHistory

func NewHistory(projectName string) *History

Define a new project history to which releases can be added in code e.g. var Project = relic.NewHistory().MustRecordReleases(...)

func (*History) Changelog

func (h *History) Changelog() (string, error)

Get the changelog for the complete history

func (*History) ChangelogForReleases

func (h *History) ChangelogForReleases(changelogTemplate *template.Template) (string, error)

func (*History) CurrentNotes

func (h *History) CurrentNotes() string

Gets the release notes for the current version

func (*History) CurrentVersion

func (h *History) CurrentVersion() Version

func (*History) MustChangelog

func (h *History) MustChangelog() string

func (*History) MustRecordReleases

func (h *History) MustRecordReleases(releaseLikes ...interface{}) *History

Like RecordReleases but will panic if the Releases list becomes invalid

func (*History) RecordReleases

func (h *History) RecordReleases(releaseLikes ...interface{}) (*History, error)

Adds releases to the History with the newest releases provided first (so latest is at top). Releases can be specified by pairs of version (string or struct), notes (string) or by sequence of Release (struct) or mixtures thereof.

func (*History) Release

func (h *History) Release(versionLike interface{}) (Release, error)

Gets the Release for version given in versionString

func (*History) WithChangelogTemplate

func (h *History) WithChangelogTemplate(tmpl *template.Template) *History

Change the default changelog template from DefaultChangelogTemplate

type Release

type Release struct {
	Version Version
	Notes   string
}

type Version

type Version struct {
	// contains filtered or unexported fields
}

func AsVersion

func AsVersion(versionLike interface{}) (Version, error)

func ParseVersion

func ParseVersion(versionString string) (Version, error)

func (Version) Major

func (v Version) Major() uint8

func (Version) Minor

func (v Version) Minor() uint8

func (Version) Patch

func (v Version) Patch() uint8

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
cmd/changelog command
cmd/notes command
cmd/version command

Jump to

Keyboard shortcuts

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