ocalver

module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0

README

🏷 ocalver - Opinionated CalVer generator

PkgGoDev Go Report Card test Coverage Status release ocalver

ocalver generates strings/versions based on the status of a git repository and the current date. I attempted to get a format which is SemVer 2.x compliant, although as the CalVer definition doesn't seem strictly define it implements an opinionated interpretation of it.

Format

                                              + YEAR - 2000
                                              |
                                              |  + DAY OF THE YEAR
                                              |  |
                                              |  |   + RELEASE ITERATION / DAY
                                              |  |   |
                                              |  |   | + PRERELEASE KEY (CONFIGURABLE)
     + YEAR - 2000                            |  |   | |
     |                                        |  |   | |  + PRELEASE ITERATION / DAY
     |  + DAY OF THE YEAR                     |  |   | |  |
     |  |                                     |  |   | |  | + PRERELEASE COMMIT HASH
     |  |   + RELEASE ITERATION / DAY         |  |   | |  | |
     +> +-> v                                 +> +-> v +> v +------>
     20.315.0                                 20.315.0-rc.0+5971883a

     ^ RELEASE                                ^ PRERELASE

TL:DR

~$ date
Tue 10 Nov 2020 15:58:09 GMT

~$ git init
Initialized empty Git repository in /tmp/demo/.git/

~$ touch .gitkeep ; git add . ; git commit -m"init"
[main (root-commit) 5971883] init
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .gitkeep

~$ git tag $(ocalver)
~$ git tag | cat
20.315.0

~$ ocalver
20.315.1

~$ ocalver -p rc
20.315.1-rc.1+5971883a

Install

Go
~$ go install github.com/mvisonneau/ocalver/cmd/ocalver@latest
Snapcraft

Get it from the Snap Store

~$ snap install ocalver
Homebrew
~$ brew install mvisonneau/tap/ocalver
Docker
~$ docker run -it --rm docker.io/mvisonneau/ocalver
or
~$ docker run -it --rm ghcr.io/mvisonneau/ocalver
Scoop
~$ scoop bucket add https://github.com/mvisonneau/scoops
~$ scoop install ocalver
Binaries, DEB and RPM packages

Have a look onto the latest release page to pick your flavor and version. Here is an helper to fetch the most recent one:

~$ export VERSION=$(curl -s "https://api.github.com/repos/mvisonneau/ocalver/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# Binary (eg: linux/amd64)
~$ wget https://github.com/mvisonneau/ocalver/releases/download/${VERSION}/ocalver_${VERSION}_linux_amd64.tar.gz
~$ tar zxvf ocalver_${VERSION}_linux_amd64.tar.gz -C /usr/local/bin

# DEB package (eg: linux/386)
~$ wget https://github.com/mvisonneau/ocalver/releases/download/${VERSION}/ocalver_${VERSION}_linux_386.deb
~$ dpkg -i ocalver_${VERSION}_linux_386.deb

# RPM package (eg: linux/arm64)
~$ wget https://github.com/mvisonneau/ocalver/releases/download/${VERSION}/ocalver_${VERSION}_linux_arm64.rpm
~$ rpm -ivh ocalver_${VERSION}_linux_arm64.rpm

Usage

~$ ocalver --help
NAME:
   ocalver - Opinionated CalVer generator

USAGE:
   ocalver [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --pre pre, -p pre                generates a pre release using the provided value as a key
   --repository-path path, -r path  path where your git repository is available (default: ".")
   --help, -h                       show help (default: false)

Develop / Test

If you use docker, you can easily get started using :

~$ make dev-env
# You should then be able to use go commands to work onto the project, eg:
~docker$ make fmt
~docker$ ocalver

Contribute

Contributions are more than welcome! Feel free to submit a PR.

Directories

Path Synopsis
cmd
ocalver command
internal
cli
cmd
pkg

Jump to

Keyboard shortcuts

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