maulik13 dc4d1c581a feat(analyzer): update AnalyzedCommit to add flexibility in parsing a message
This provides flexibility of parsing and rendering structured messages
with more detail in the changelog and helps extract metadata from the 
message. The new structure can be used to split a message in multiple 
blocks (e.g. footer)
2021-02-23 14:25:09 +01:00
2021-02-11 19:36:20 +01:00
2019-06-15 23:16:30 +02:00
2019-05-13 10:26:20 +02:00

go-semantic-release

go-semantic-release

Release Types

Type Implemented Git tag Changelog Release Write access git Api token
github
gitlab
git
bitbucket Comming soon

Supported CI Pipelines

  • Github Actions
  • Gitlab CI
  • Travis CI
  • Custom CI, set enviroment CI=true

Download

You can download the newest version under releases

or

you can use a Docker image

docker pull nightapes/go-semantic-release:<VERSION> or docker pull docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:<VERSION>

How to use

go-semantic-release config file Create a file with the name .release.yml or anything else, but you need to set to every command -c <your config file>

Example config

commitFormat: angular
branch:
  master: release
release: 'github'
github:
  repo: "go-semantic-release"
  user: "nightapes"
assets:
  - name: ./build/go-semantic-release
    compress: false
  - name: ./build/go-semantic-release.exe
    compress: false
hooks:
  preRelease:
    - name: echo $RELEASE_VERSION
  postRelease:
    - name: echo $RELEASE_VERSION

CommitFormat

Supported formats:

Branch

You can define which kind of release should be created for different branches.

Supported release kinds:

  • release -> v1.0.0
  • rc -> v1.0.0-rc.0
  • beta -> v1.0.0-beta.0
  • alpha -> v1.0.0-alpha.0

Add a branch config to your config

branch:
  <branch-name>: <kind>

Release

At the moment we support releases to gitlab and github.

Github

You need to set the env GITHUB_TOKEN with an access token.

release: 'github'
github:
  user: "<user/group"
  repo: "<repositroyname>"
  ## Optional, if you are not using github.com
  customUrl: <https://your.github>
  ## Optional, if you want to change the default tag prefix ("v")
  tagPrefix: ""
Gitlab

You need to set the env GITLAB_ACCESS_TOKEN with an personal access token.

release: 'gitlab'
gitlab:
  repo: "<repositroyname>"  ## Example group/project
  ## Optional, if your not using gitlab.com
  customUrl: <https://your.gitlab>
  ## Optional, if you want to change the default tag prefix ("v")
  tagPrefix: ""
Git only

Only via https at the moment. You need write access to your git repository

release: 'git'
git:
  email: "<email>" # Used for creating tag
  user: "<user>" : # Used for creating tag and pushing
  auth: "<token>" # Used for pushing, can be env "$GIT_TOKEN", will be replaced with env
  ## Optional, if you want to change the default tag prefix ("v")
  tagPrefix: ""

Assets

You can upload assets to a release

Support for gitlab and github. If you want, you can let the file be compressed before uploading

assets:
  - name: ./build/go-semantic-release
    compress: false

Hooks

Hooks will run when calling release. Hooks run only if a release will be triggered.

Changelog

Following variables can be used for templates:

  • Commits string
  • Version string
  • Now time.Time
  • Backtick string
  • HasDocker bool
  • HasDockerLatest bool
  • DockerRepository string
changelog:
  printAll: false ## Print all valid commits to changelog
  title: "v{{.Version}} ({{.Now.Format "2006-01-02"}})" ## Used for releases (go template)
  templatePath: "./examples/changelog.tmpl"    ## Path to a template file (go template)
Docker

You can print a help text for a docker image

changelog:
  docker: 
    latest: false ## If you uploaded a latest image
    repository: ## Your docker repository, which is used for docker run

Version

go-semantic-release has two modes for calculating the version: automatic or manual.

Automatic

Version will be calculated on the next or release command

Manual

If you don't want that go-semantic-release is calculating the version from the commits, you can set the version by hand with following command:

./go-semantic-release set 1.1.1

Print version

Print the next version, can be used to add version to your program

./go-semantic-release next // show next version (calculated by new commits since last version)
./go-semantic-release last // show last released version 

Example with go-lang

go build -ldflags "--X main.version=`./go-semantic-release next`"

Create release

./go-semantic-release release 

Build from source

go build ./cmd/go-semantic-release/

Testing

go test ./... 

Linting

curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.16.0
golangci-lint run ./...
2024-04-08 14:08:04 +12:00
Languages
Go 97.5%
Shell 2.1%
Dockerfile 0.3%
Makefile 0.1%