Skip to content

Commit

Permalink
Merge pull request #14 from maykonlf/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
maykonlsf authored Mar 24, 2022
2 parents 370daa0 + 848dc08 commit fa83d8d
Show file tree
Hide file tree
Showing 6 changed files with 794 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.13
golang 1.17.8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13-alpine3.10 as builder
FROM golang:1.17-alpine as builder
RUN mkdir /build
ADD . /build/
WORKDIR /build
Expand Down
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,28 @@ test: fmtcheck
@sh -c "go test ./... -timeout=2m -parallel=4"

build:
CGO_ENABLED=0
GOOS=linux
@go build -o semver ./cmd/semver
@go build -o ./semver ./cmd/semver

.PHONY: default test cover fmt fmtcheck lint
build-linux-amd64:
@mkdir -p ./dist/linux-amd64
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./dist/linux-amd64/semver ./cmd/semver
@echo "./dist/linux-amd64/semver (linux/amd64)"

build-windows-amd64:
@mkdir -p ./dist/windows-amd64
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ./dist/windows-amd64/semver.exe ./cmd/semver
@echo "./dist/windows-amd64/semver.exe (windows/amd64)"

build-macos-arm64:
@mkdir -p ./dist/macos-arm64
@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./dist/macos-arm64/semver ./cmd/semver
@echo "./dist/darwin-arm64/semver (darwin/arm64 - MacOS M1)"

build-macos-amd64:
@mkdir -p ./dist/macos-amd64
@CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./dist/macos-amd64/semver ./cmd/semver
@echo "./dist/darwin-amd64/semver (darwin/amd64 - MacOS Intel)"

build-all: build build-linux-amd64 build-windows-amd64 build-macos-arm64 build-macos-amd64

.PHONY: default test cover fmt fmtcheck lint build
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
# Semantic Versioning Tool

An easy to use CLI tool to manage your projects current version and its upgrades according to the Semantic Versioning specification.

An easy to use CLI tool to manage your projects current version and its upgrades according to the Semantic Versioning
specification.

## Getting Started

### Install

If you already have golang installed you can install by running the command:

```sh
go get -u github.com/maykonlf/semver-cli/cmd/semver
go install github.com/maykonlf/semver-cli/cmd/semver@latest
```

### check install

Check if the semver was instaled running the command:

```sh
semver
```


### Init semver

To start managing your project versions enter into the project folder, then run:

```sh
semver init
```

This command will start the versioning based on release version v1.0.0. If you want to start with another version number you car run instead:
This command will start the versioning based on release version v1.0.0. If you want to start with another version number
you car run instead:

```sh
semver init \
--release [base release version] \
Expand All @@ -34,62 +41,79 @@ semver init \
[--force] # to override an already initialized semver in the current directory.
```


## Usage

### Get current version

#### Alpha

Returns the current alpha version (if none will return and "-alpha.0" version).

```sh
$ semver get alpha
v1.0.0-alpha.6
```

#### Beta

Returns the current beta version (if none will return and "-beta.0" version).

```sh
$ semver get beta
v1.0.0-beta.3
```

#### Release Candidate

Returns the current release candidate version (if none will return and "-rc.0" version).

```sh
$ semver get rc
v1.0.0-rc.1
```

#### Release

Returns the current release version.

```sh
$ semver get release
v1.0.0
```

### Upgrade version

#### Alpha

Increment the current alpha version by 1. If none starts with 1.

```sh
$ semver up alpha
v1.0.0-alpha.7
```

#### Beta

Increment the current beta version by 1. If none starts with 1.

```sh
$ semver up beta
v1.0.0-beta.4
```

#### Release Candidate

Increment the current release candidate version by 1. If none starts with 1.

```sh
$ semver up rc
v1.0.0-rc.2
```

#### Release

Upgrade an alpha, beta or rc to its final release version. Also increments the patch number by 1 to a release version:

```sh
$ semver up release
v1.0.0
Expand All @@ -99,13 +123,17 @@ v1.0.1
```

#### Minor
Increments release minor version number by 1 (useful when you start working on next release version) and clear alpha, beta, rc and patch number.

Increments release minor version number by 1 (useful when you start working on next release version) and clear alpha,
beta, rc and patch number.

```sh
$ semver up minor
v1.1.0
```

Before you upgrade the minor version the next versions will be generated based on this new minor version.

```sh
$ semver up alpha
v1.1.0-alpha.1
Expand All @@ -118,13 +146,17 @@ v1.1.0-rc.1
```

#### Major
Upgrades the current version to the next major version (when you starts working on a new version with branking changes) and clear alpha, beta, rc, patch and minor number.

Upgrades the current version to the next major version (when you starts working on a new version with branking changes)
and clear alpha, beta, rc, patch and minor number.

```sh
$ semver up major
v2.0.0
```

Before them, your next versions will be generated based on this new version.

```sh
$ semver up alpha
v2.0.0-alpha.1
Expand Down
32 changes: 24 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
module github.com/maykonlf/semver-cli

go 1.13
go 1.17

require (
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/smartystreets/goconvey v1.6.4
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
)

require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.1
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.7
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit fa83d8d

Please sign in to comment.