semv

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 10 Imported by: 0

README





:bookmark:
Git Semantic Versioning

git-semv: This is a FORK of the Git plugin for Semantic Versioning.





GitHub Workflow Status GitHub Workflow Status GitHub Release MIT License Go Documentation

The usefulness of Semantic Versioning has been accepted by OSS in advance. And, with the appearance of Go modules, Semantic Versioning became indispensable for the development of the Go library. However, git tag used for versioning can not support pre-releases and sorts including build information for managing Semantic Versioning. Also, it is not easy to increment the version. This git-semv is a CLI tool for solving these problems and functions as git subcommand.

Japanese: https://tomohisaoda.com/posts/2018/do-semantic-versioning-for-app.html

Installation

Download the binary in Github Releases and place it in the directory where $PATH passed. Or, you can download using go get depending on the version of Go1.11 or higher.

$ go get -u github.com/Vr00mm/git-semv/cmd/git-semv

Usage

Show list:

# Only release versions
$ git semv
v0.0.1
v0.0.2
v1.0.0
v1.1.0
v1.1.1

# All versions including pre-release
$ git semv -a
v0.0.1
v0.0.2
v1.0.0-alpha.0+a2a784b.Vr00mm
v1.0.0-beta.0+ba8a247.foobar
v1.0.0-rc.0
v1.0.0-rc.1
v1.0.0
v1.1.0
v1.1.1
v2.0.0-alpha.0

Show latest version:

$ git semv now
v1.1.1

Show next version(major|minor|patch):

# Next patch version
$ git semv patch
v1.1.2

# Next minor version
$ git semv minor
v1.2.0

# Next major version
$ git semv major
v2.0.0

Use options(pre|pre-name|build|build-name|bump):

# Next pre-release as major
$ git semv major --pre
v2.0.0-alpha.1

# Specify pre-release name as major
$ git semv major --pre-name beta
v2.0.0-beta.0

# Next minor version with build info
$ git semv minor --build
v1.2.0+9125b23.Vr00mm

# Specify build name
$ git semv minor --build-name superproject
v1.2.0+superproject

# Create tag and Push origin
$ git semv patch --bump
Bumped version to v1.1.2
#==> git tag v1.1.2 && git push origin v1.1.2

VS.

motemen/gobump

gobump will increment the version according to semver in version in the source code. On the other hand, git-semv does not do anything to the source code. Even if you do, you just create a tag and push it remotely. When focusing on Go, Go can add version and other information to the build, so there is no need to manage version in code. Also, in other languages, you can easily replace them in code by combining with commands such as sed.

and git-semv supports versioning of pre-release and build information.

Development flow

The assumed development flow is...

  1. Development
  2. Remote push
  3. Pull-request create
  4. Continuous Integration
  5. Master branch merge
  6. Tag create and push(git-semv)
  7. Continuous Integration
  8. Release create(goreleaser)

Generally, development in Go will upload the product binary to github releases and release the product. There is a great tool called goreleaser which makes that work easier. By running this tool on the CI, we will automatically release the binary after pushing the created tag. And git-semv solves troublesome versioning and tag creation problem which is the next bottleneck.

Contribution

  1. Fork (https://github.com/Vr00mm/git-semv/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Author

Vr00mm

Documentation

Index

Constants

View Source
const (
	// ExitOK for exit code
	ExitOK int = 0

	// ExitErr for exit code
	ExitErr int = 1
)

Variables

This section is empty.

Functions

func RunCLI

func RunCLI(env Env) int

RunCLI runs for CLI

Types

type Commits

type Commits []struct {
	Sha    string `json:"sha"`
	NodeID string `json:"node_id"`
	Commit struct {
		Author struct {
			Name  string    `json:"name"`
			Email string    `json:"email"`
			Date  time.Time `json:"date"`
		} `json:"author"`
		Committer struct {
			Name  string    `json:"name"`
			Email string    `json:"email"`
			Date  time.Time `json:"date"`
		} `json:"committer"`
		Message string `json:"message"`
		Tree    struct {
			Sha string `json:"sha"`
			URL string `json:"url"`
		} `json:"tree"`
		URL          string `json:"url"`
		CommentCount int    `json:"comment_count"`
		Verification struct {
			Verified  bool        `json:"verified"`
			Reason    string      `json:"reason"`
			Signature interface{} `json:"signature"`
			Payload   interface{} `json:"payload"`
		} `json:"verification"`
	} `json:"commit"`
	URL         string `json:"url"`
	HTMLURL     string `json:"html_url"`
	CommentsURL string `json:"comments_url"`
	Author      struct {
		Login             string `json:"login"`
		ID                int    `json:"id"`
		NodeID            string `json:"node_id"`
		AvatarURL         string `json:"avatar_url"`
		GravatarID        string `json:"gravatar_id"`
		URL               string `json:"url"`
		HTMLURL           string `json:"html_url"`
		FollowersURL      string `json:"followers_url"`
		FollowingURL      string `json:"following_url"`
		GistsURL          string `json:"gists_url"`
		StarredURL        string `json:"starred_url"`
		SubscriptionsURL  string `json:"subscriptions_url"`
		OrganizationsURL  string `json:"organizations_url"`
		ReposURL          string `json:"repos_url"`
		EventsURL         string `json:"events_url"`
		ReceivedEventsURL string `json:"received_events_url"`
		Type              string `json:"type"`
		SiteAdmin         bool   `json:"site_admin"`
	} `json:"author"`
	Committer struct {
		Login             string `json:"login"`
		ID                int    `json:"id"`
		NodeID            string `json:"node_id"`
		AvatarURL         string `json:"avatar_url"`
		GravatarID        string `json:"gravatar_id"`
		URL               string `json:"url"`
		HTMLURL           string `json:"html_url"`
		FollowersURL      string `json:"followers_url"`
		FollowingURL      string `json:"following_url"`
		GistsURL          string `json:"gists_url"`
		StarredURL        string `json:"starred_url"`
		SubscriptionsURL  string `json:"subscriptions_url"`
		OrganizationsURL  string `json:"organizations_url"`
		ReposURL          string `json:"repos_url"`
		EventsURL         string `json:"events_url"`
		ReceivedEventsURL string `json:"received_events_url"`
		Type              string `json:"type"`
		SiteAdmin         bool   `json:"site_admin"`
	} `json:"committer"`
	Parents []struct {
		Sha     string `json:"sha"`
		URL     string `json:"url"`
		HTMLURL string `json:"html_url"`
	} `json:"parents"`
}

type Env

type Env struct {
	Out, Err io.Writer
	Args     []string
	Version  string
	Commit   string
	Date     string
}

Env struct

type List

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

List struct

func GetList

func GetList(url string) (*List, error)

GetList returns List

func (*List) FindSimilar

func (l *List) FindSimilar(v semver.Version) *Semv

FindSimilar finds similar one

func (*List) Latest

func (l *List) Latest() *Semv

Latest gets latest version from List

func (*List) OnlyPreRelease

func (l *List) OnlyPreRelease() *List

OnlyPreRelease includes only pre-release

func (*List) String

func (l *List) String() string

String to string

func (*List) WithoutPreRelease

func (l *List) WithoutPreRelease() *List

WithoutPreRelease excludes pre-release

type Semv

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

Semv struct

func Latest

func Latest(url string) (*Semv, error)

Latest returns latest version

func MustNew

func MustNew(s string) *Semv

MustNew creates Semv

func (*Semv) Build

func (v *Semv) Build(name string, url string) (*Semv, error)

Build retuns

func (*Semv) IsEmpty

func (v *Semv) IsEmpty() bool

IsEmpty checks empty

func (*Semv) Next

func (v *Semv) Next(target string) *Semv

Next returns next version

func (*Semv) PreRelease

func (v *Semv) PreRelease(name string) (*Semv, error)

PreRelease retuns

func (*Semv) String

func (v *Semv) String() string

String to string

type Tags

type Tags []struct {
	Name       string `json:"name"`
	ZipballURL string `json:"zipball_url"`
	TarballURL string `json:"tarball_url"`
	Commit     struct {
		Sha string `json:"sha"`
		URL string `json:"url"`
	} `json:"commit"`
	NodeID string `json:"node_id"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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