You've already forked go-semantic-release
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3731fa6e55 | ||
|
|
15a17e546b | ||
|
|
037983df1e | ||
|
|
01af837b40 | ||
|
|
0f1275fc30 |
14
README.md
14
README.md
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
## Release Types
|
## Release Types
|
||||||
|
|
||||||
| Type | Implemendet | Git tag | Changelog | Release | Write access git | Api token |
|
| Type | Implemented | Git tag | Changelog | Release | Write access git | Api token |
|
||||||
| ----------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
|
| ----------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
|
||||||
| `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
|
| `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: |
|
| `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
|
||||||
@@ -60,7 +60,7 @@ hooks:
|
|||||||
|
|
||||||
#### CommitFormat
|
#### CommitFormat
|
||||||
|
|
||||||
Set the commit format, at the moment we support ony [angular](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format), more coming soon.
|
Set the commit format, at the moment we support only [angular](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format), more coming soon.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
commitFormat: angular
|
commitFormat: angular
|
||||||
@@ -97,8 +97,10 @@ release: 'github'
|
|||||||
github:
|
github:
|
||||||
user: "<user/group"
|
user: "<user/group"
|
||||||
repo: "<repositroyname>"
|
repo: "<repositroyname>"
|
||||||
## Optional, if your not using github.com
|
## Optional, if you are not using github.com
|
||||||
customUrl: <https://your.github>
|
customUrl: <https://your.github>
|
||||||
|
## Optional, if you want to change the default tag prefix ("v")
|
||||||
|
tagPrefix: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Gitlab
|
##### Gitlab
|
||||||
@@ -112,6 +114,8 @@ gitlab:
|
|||||||
repo: "<repositroyname>" ## Example group/project
|
repo: "<repositroyname>" ## Example group/project
|
||||||
## Optional, if your not using gitlab.com
|
## Optional, if your not using gitlab.com
|
||||||
customUrl: <https://your.gitlab>
|
customUrl: <https://your.gitlab>
|
||||||
|
## Optional, if you want to change the default tag prefix ("v")
|
||||||
|
tagPrefix: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Git only
|
##### Git only
|
||||||
@@ -125,6 +129,8 @@ git:
|
|||||||
email: "<email>" # Used for creating tag
|
email: "<email>" # Used for creating tag
|
||||||
user: "<user>" : # Used for creating tag and pushing
|
user: "<user>" : # Used for creating tag and pushing
|
||||||
auth: "<token>" # Used for pushing, can be env "$GIT_TOKEN", will be replaced with env
|
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: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +182,7 @@ changelog:
|
|||||||
|
|
||||||
### Version
|
### Version
|
||||||
|
|
||||||
`go-semantic-release` has two modes for calcualting the version: automatic or manual.
|
`go-semantic-release` has two modes for calculating the version: automatic or manual.
|
||||||
|
|
||||||
#### Automatic
|
#### Automatic
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var commits []shared.Commit
|
commits := make(map[string]shared.Commit)
|
||||||
var foundEnd bool
|
var foundEnd bool
|
||||||
|
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
@@ -147,55 +147,25 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
|
|||||||
|
|
||||||
if !foundEnd {
|
if !foundEnd {
|
||||||
log.Tracef("Found commit with hash %s", c.Hash.String())
|
log.Tracef("Found commit with hash %s", c.Hash.String())
|
||||||
commit := shared.Commit{
|
commits[c.Hash.String()] = shared.Commit{
|
||||||
Message: c.Message,
|
Message: c.Message,
|
||||||
Author: c.Committer.Name,
|
Author: c.Committer.Name,
|
||||||
Hash: c.Hash.String(),
|
Hash: c.Hash.String(),
|
||||||
}
|
}
|
||||||
commits = append(commits, commit)
|
|
||||||
|
|
||||||
if len(c.ParentHashes) == 2 {
|
|
||||||
parent, err := g.Repository.CommitObject(c.ParentHashes[1])
|
|
||||||
if err == nil {
|
|
||||||
commit := shared.Commit{
|
|
||||||
Message: parent.Message,
|
|
||||||
Author: parent.Committer.Name,
|
|
||||||
Hash: parent.Hash.String(),
|
|
||||||
}
|
|
||||||
commits = append(commits, commit)
|
|
||||||
log.Tracef("Found parent check for merge commits for hash %s", c.ParentHashes[1].String())
|
|
||||||
|
|
||||||
commits = append(commits, g.getParents(parent)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return commits, errors.Wrap(err, "Could not read commits, check git clone depth in your ci")
|
return nil, errors.Wrap(err, "Could not read commits, check git clone depth in your ci")
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits, nil
|
l := make([]shared.Commit, 0)
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GitUtil) getParents(current *object.Commit) []shared.Commit {
|
for _, value := range commits {
|
||||||
commits := make([]shared.Commit, 0)
|
l = append(l, value)
|
||||||
for _, i2 := range current.ParentHashes {
|
|
||||||
parent, err := g.Repository.CommitObject(i2)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
commit := shared.Commit{
|
|
||||||
Message: parent.Message,
|
|
||||||
Author: parent.Committer.Name,
|
|
||||||
Hash: parent.Hash.String(),
|
|
||||||
}
|
|
||||||
commits = append(commits, commit)
|
|
||||||
if len(parent.ParentHashes) == 1 {
|
|
||||||
commits = append(commits, g.getParents(parent)...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return commits
|
|
||||||
|
return l, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,12 @@ func (g *Client) GetCompareURL(oldVersion, newVersion string) string {
|
|||||||
// CreateRelease creates release on remote
|
// CreateRelease creates release on remote
|
||||||
func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog, _ *assets.Set) error {
|
func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog, _ *assets.Set) error {
|
||||||
|
|
||||||
tag := "v" + releaseVersion.Next.Version.String()
|
tagPrefix := config.DefaultTagPrefix
|
||||||
|
if g.config.TagPrefix != nil{
|
||||||
|
tagPrefix = *g.config.TagPrefix
|
||||||
|
}
|
||||||
|
tag := tagPrefix + releaseVersion.Next.Version.String()
|
||||||
|
|
||||||
g.log.Infof("create release with version %s", tag)
|
g.log.Infof("create release with version %s", tag)
|
||||||
|
|
||||||
head, err := g.git.Repository.Head()
|
head, err := g.git.Repository.Head()
|
||||||
|
|||||||
@@ -90,7 +90,11 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC
|
|||||||
// CreateRelease creates release on remote
|
// CreateRelease creates release on remote
|
||||||
func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
|
func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
|
||||||
|
|
||||||
tag := "v" + releaseVersion.Next.Version.String()
|
tagPrefix := config.DefaultTagPrefix
|
||||||
|
if g.config.TagPrefix != nil{
|
||||||
|
tagPrefix = *g.config.TagPrefix
|
||||||
|
}
|
||||||
|
tag := tagPrefix + releaseVersion.Next.Version.String()
|
||||||
g.log.Debugf("create release with version %s", tag)
|
g.log.Debugf("create release with version %s", tag)
|
||||||
|
|
||||||
prerelease := releaseVersion.Next.Version.Prerelease() != ""
|
prerelease := releaseVersion.Next.Version.Prerelease() != ""
|
||||||
|
|||||||
@@ -98,7 +98,11 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC
|
|||||||
// CreateRelease creates release on remote
|
// CreateRelease creates release on remote
|
||||||
func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
|
func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
|
||||||
|
|
||||||
tag := "v" + releaseVersion.Next.Version.String()
|
tagPrefix := config.DefaultTagPrefix
|
||||||
|
if g.config.TagPrefix != nil{
|
||||||
|
tagPrefix = *g.config.TagPrefix
|
||||||
|
}
|
||||||
|
tag := tagPrefix + releaseVersion.Next.Version.String()
|
||||||
g.Release = tag
|
g.Release = tag
|
||||||
g.log.Infof("create release with version %s", tag)
|
g.log.Infof("create release with version %s", tag)
|
||||||
url := fmt.Sprintf("%s/projects/%s/releases", g.apiURL, util.PathEscape(g.config.Repo))
|
url := fmt.Sprintf("%s/projects/%s/releases", g.apiURL, util.PathEscape(g.config.Repo))
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import (
|
|||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultTagPrefix = "v"
|
||||||
|
)
|
||||||
|
|
||||||
// ChangelogConfig struct
|
// ChangelogConfig struct
|
||||||
type ChangelogConfig struct {
|
type ChangelogConfig struct {
|
||||||
PrintAll bool `yaml:"printAll,omitempty"`
|
PrintAll bool `yaml:"printAll,omitempty"`
|
||||||
@@ -44,6 +48,7 @@ type GitHubProvider struct {
|
|||||||
User string `yaml:"user"`
|
User string `yaml:"user"`
|
||||||
CustomURL string `yaml:"customUrl,omitempty"`
|
CustomURL string `yaml:"customUrl,omitempty"`
|
||||||
AccessToken string
|
AccessToken string
|
||||||
|
TagPrefix *string `yaml:"tagPrefix,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitLabProvider struct
|
// GitLabProvider struct
|
||||||
@@ -51,6 +56,7 @@ type GitLabProvider struct {
|
|||||||
Repo string `yaml:"repo"`
|
Repo string `yaml:"repo"`
|
||||||
CustomURL string `yaml:"customUrl,omitempty"`
|
CustomURL string `yaml:"customUrl,omitempty"`
|
||||||
AccessToken string
|
AccessToken string
|
||||||
|
TagPrefix *string `yaml:"tagPrefix,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitProvider struct
|
// GitProvider struct
|
||||||
@@ -59,6 +65,7 @@ type GitProvider struct {
|
|||||||
Username string `yaml:"user"`
|
Username string `yaml:"user"`
|
||||||
Auth string `yaml:"auth"`
|
Auth string `yaml:"auth"`
|
||||||
SSH bool `yaml:"ssh"`
|
SSH bool `yaml:"ssh"`
|
||||||
|
TagPrefix *string `yaml:"tagPrefix,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hooks struct
|
// Hooks struct
|
||||||
|
|||||||
Reference in New Issue
Block a user