2019-05-13 22:36:24 +02:00
|
|
|
# go-semantic-release
|
|
|
|
|
|
2020-02-19 19:40:24 +01:00
|
|
|

|
|
|
|
|
|
2019-06-10 16:24:44 +02:00
|
|
|
## Release Types
|
|
|
|
|
|
2021-01-21 21:39:52 +01:00
|
|
|
| Type | Implemented | Git tag | Changelog | Release | Write access git | Api token |
|
2020-01-06 12:44:10 +01:00
|
|
|
| ----------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
|
|
|
|
|
| `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
|
|
|
|
|
| `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
|
|
|
|
|
| `git` | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | |
|
|
|
|
|
| `bitbucket` | Comming soon | :white_check_mark: | | | :white_check_mark: | |
|
2019-06-10 16:24:44 +02:00
|
|
|
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
## Supported CI Pipelines
|
2019-06-10 16:24:44 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
* Github Actions
|
|
|
|
|
* Gitlab CI
|
|
|
|
|
* Travis CI
|
|
|
|
|
* Custom CI, set enviroment `CI=true`
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2020-02-07 16:36:38 +01:00
|
|
|
## Download
|
|
|
|
|
|
|
|
|
|
You can download the newest version under [releases](https://github.com/Nightapes/go-semantic-release/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>`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
## How to use
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
`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>`
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
### Example config
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
```yml
|
|
|
|
|
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
|
2020-01-05 18:53:23 +01:00
|
|
|
hooks:
|
|
|
|
|
preRelease:
|
|
|
|
|
- name: echo $RELEASE_VERSION
|
|
|
|
|
postRelease:
|
|
|
|
|
- name: echo $RELEASE_VERSION
|
2019-08-31 17:05:10 +02:00
|
|
|
```
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
#### CommitFormat
|
2019-05-13 22:36:24 +02:00
|
|
|
|
2021-01-21 21:41:14 +01:00
|
|
|
Supported formats:
|
|
|
|
|
|
|
|
|
|
* [angular](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format)
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
commitFormat: angular
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* [conventional](https://www.conventionalcommits.org/en/v1.0.0/#summaryhttps://www.conventionalcommits.org/en/v1.0.0/#summary)
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
commitFormat: conventional
|
|
|
|
|
```
|
2019-08-31 17:05:10 +02:00
|
|
|
|
|
|
|
|
#### 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
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
branch:
|
|
|
|
|
<branch-name>: <kind>
|
|
|
|
|
```
|
|
|
|
|
|
2020-01-05 18:53:23 +01:00
|
|
|
#### Release
|
2019-08-31 17:05:10 +02:00
|
|
|
|
|
|
|
|
At the moment we support releases to gitlab and github.
|
|
|
|
|
|
|
|
|
|
##### Github
|
|
|
|
|
|
2019-09-15 20:13:17 +02:00
|
|
|
You need to set the env `GITHUB_TOKEN` with an access token.
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
```yml
|
|
|
|
|
release: 'github'
|
|
|
|
|
github:
|
|
|
|
|
user: "<user/group"
|
|
|
|
|
repo: "<repositroyname>"
|
2021-01-21 21:39:52 +01:00
|
|
|
## Optional, if you are not using github.com
|
2019-09-16 08:23:21 +02:00
|
|
|
customUrl: <https://your.github>
|
2021-01-21 21:39:52 +01:00
|
|
|
## Optional, if you want to change the default tag prefix ("v")
|
|
|
|
|
tagPrefix: ""
|
2019-08-31 17:05:10 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
##### Gitlab
|
|
|
|
|
|
2019-09-15 20:13:17 +02:00
|
|
|
You need to set the env `GITLAB_ACCESS_TOKEN` with an personal access token.
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
```yml
|
|
|
|
|
release: 'gitlab'
|
|
|
|
|
gitlab:
|
|
|
|
|
repo: "<repositroyname>" ## Example group/project
|
|
|
|
|
## Optional, if your not using gitlab.com
|
2019-09-16 08:23:21 +02:00
|
|
|
customUrl: <https://your.gitlab>
|
2021-01-21 21:39:52 +01:00
|
|
|
## Optional, if you want to change the default tag prefix ("v")
|
|
|
|
|
tagPrefix: ""
|
2019-08-31 17:05:10 +02:00
|
|
|
```
|
|
|
|
|
|
2020-01-05 18:53:23 +01:00
|
|
|
##### Git only
|
|
|
|
|
|
|
|
|
|
Only via https at the moment. You need write access to your git repository
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
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
|
2021-01-21 21:39:52 +01:00
|
|
|
## Optional, if you want to change the default tag prefix ("v")
|
|
|
|
|
tagPrefix: ""
|
2020-01-05 18:53:23 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
#### 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
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
assets:
|
|
|
|
|
- name: ./build/go-semantic-release
|
|
|
|
|
compress: false
|
|
|
|
|
```
|
|
|
|
|
|
2020-01-05 18:53:23 +01:00
|
|
|
#### Hooks
|
|
|
|
|
|
|
|
|
|
Hooks will run when calling `release`. Hooks run only if a release will be triggered.
|
|
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
#### Changelog
|
|
|
|
|
|
2021-02-22 20:59:01 +01:00
|
|
|
Following variables and objects can be used for templates:
|
|
|
|
|
|
|
|
|
|
__Top level__
|
|
|
|
|
|
|
|
|
|
| Field | Type | Description |
|
|
|
|
|
| -------- | ------ | ----- |
|
|
|
|
|
| `Commits` | string | Fully rendered commit messages. This is left for backward compatibility. |
|
|
|
|
|
| `CommitsContent` | commitsContent | Raw parsed commit data. Use this if you want to customize the output. |
|
|
|
|
|
| `Version` | string | Next release version |
|
|
|
|
|
| `Now` | time.Time | Current time of generating changelog |
|
|
|
|
|
| `Backtick` | string | Backtick character |
|
|
|
|
|
| `HasDocker` | bool | If a docker repository is set in the config. |
|
|
|
|
|
| `HasDockerLatest` | bool | If `latest` image was uploaded |
|
|
|
|
|
| `DockerRepository` | string | Docker repository |
|
|
|
|
|
|
|
|
|
|
__commitsContent__
|
|
|
|
|
|
|
|
|
|
| Field | Type | Description |
|
|
|
|
|
| -------- | ------ | ----- |
|
|
|
|
|
| `Commits` | map[string][]AnalyzedCommit | Commits grouped by commit type |
|
|
|
|
|
| `BreakingChanges` | []AnalyzedCommit | Analyzed commit structure |
|
|
|
|
|
| `Order` | []string | Ordered list of types |
|
|
|
|
|
| `HasURL` | bool | If a URL is available for commits |
|
|
|
|
|
| `URL` | string | URL for to the commit with {{hash}} suffix |
|
|
|
|
|
|
|
|
|
|
__AnalyzedCommit__
|
|
|
|
|
|
|
|
|
|
| Field | Type | Description |
|
|
|
|
|
| -------- | ------ | ----- |
|
|
|
|
|
| `Commit` | Commit | Original GIT commit |
|
|
|
|
|
| `Tag` | string | Type of commit (e.g. feat, fix, ...) |
|
|
|
|
|
| `TagString` | string | Full name of the type |
|
|
|
|
|
| `Scope` | bool | Scope value from the commit |
|
|
|
|
|
| `Subject` | string | URL for to the commit with {{hash}} suffix |
|
|
|
|
|
| `MessageBlocks` | map[string][]MessageBlock | Different sections of a message (e.g. body, footer etc.) |
|
|
|
|
|
| `IsBreaking` | bool | If this commit contains a breaking change |
|
|
|
|
|
| `Print` | bool | Should this commit be included in Changelog output |
|
|
|
|
|
|
|
|
|
|
__Commit__
|
|
|
|
|
|
|
|
|
|
| Field | Type | Description |
|
|
|
|
|
| -------- | ------ | ----- |
|
|
|
|
|
| `Message` | string | Original git commit message |
|
|
|
|
|
| `Author` | string | Name of the author |
|
|
|
|
|
| `Hash` | string | Commit hash value "|
|
|
|
|
|
|
|
|
|
|
__MessageBlock__
|
|
|
|
|
|
|
|
|
|
| Field | Type | Description |
|
|
|
|
|
| -------- | ------ | ----- |
|
|
|
|
|
| `Label` | string | Label for a block (optional). This will usually be a token used in a footer |
|
|
|
|
|
| `Content` | string | The parsed content of a block |
|
2019-09-22 15:50:12 +02:00
|
|
|
|
2019-08-31 17:05:10 +02:00
|
|
|
```yml
|
|
|
|
|
changelog:
|
|
|
|
|
printAll: false ## Print all valid commits to changelog
|
2019-09-22 15:50:12 +02:00
|
|
|
title: "v{{.Version}} ({{.Now.Format "2006-01-02"}})" ## Used for releases (go template)
|
|
|
|
|
templatePath: "./examples/changelog.tmpl" ## Path to a template file (go template)
|
2019-08-31 17:05:10 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
##### Docker
|
|
|
|
|
|
|
|
|
|
You can print a help text for a docker image
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
changelog:
|
|
|
|
|
docker:
|
|
|
|
|
latest: false ## If you uploaded a latest image
|
|
|
|
|
repository: ## Your docker repository, which is used for docker run
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Version
|
|
|
|
|
|
2021-01-21 21:39:52 +01:00
|
|
|
`go-semantic-release` has two modes for calculating the version: automatic or manual.
|
2019-08-31 17:05:10 +02:00
|
|
|
|
|
|
|
|
#### 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:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./go-semantic-release set 1.1.1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Print version
|
|
|
|
|
|
|
|
|
|
Print the next version, can be used to add version to your program
|
|
|
|
|
|
|
|
|
|
```bash
|
2020-02-18 19:19:09 +01:00
|
|
|
./go-semantic-release next // show next version (calculated by new commits since last version)
|
|
|
|
|
./go-semantic-release last // show last released version
|
2019-08-31 17:05:10 +02:00
|
|
|
```
|
|
|
|
|
Example with go-lang
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
go build -ldflags "--X main.version=`./go-semantic-release next`"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Create release
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./go-semantic-release release
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Build from source
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
go build ./cmd/go-semantic-release/
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Testing
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
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 ./...
|
2019-09-16 08:23:21 +02:00
|
|
|
```
|