diff --git a/README.md b/README.md index 244f33e..ddff153 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## 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: | | `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | @@ -74,7 +74,6 @@ Supported formats: commitFormat: conventional ``` - #### Branch You can define which kind of release should be created for different branches. @@ -106,8 +105,10 @@ release: 'github' github: user: "" - ## Optional, if your not using github.com + ## Optional, if you are not using github.com customUrl: + ## Optional, if you want to change the default tag prefix ("v") + tagPrefix: "" ``` ##### Gitlab @@ -121,6 +122,8 @@ gitlab: repo: "" ## Example group/project ## Optional, if your not using gitlab.com customUrl: + ## Optional, if you want to change the default tag prefix ("v") + tagPrefix: "" ``` ##### Git only @@ -134,6 +137,8 @@ git: email: "" # Used for creating tag user: "" : # Used for creating tag and pushing auth: "" # 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: "" ``` @@ -185,7 +190,7 @@ changelog: ### 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 diff --git a/internal/releaser/git/git.go b/internal/releaser/git/git.go index 61245e9..cde0a1d 100644 --- a/internal/releaser/git/git.go +++ b/internal/releaser/git/git.go @@ -67,7 +67,12 @@ func (g *Client) GetCompareURL(oldVersion, newVersion string) string { // CreateRelease creates release on remote 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) head, err := g.git.Repository.Head() diff --git a/internal/releaser/github/github.go b/internal/releaser/github/github.go index 07adb07..5668ccc 100644 --- a/internal/releaser/github/github.go +++ b/internal/releaser/github/github.go @@ -90,7 +90,11 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC // CreateRelease creates release on remote 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) prerelease := releaseVersion.Next.Version.Prerelease() != "" diff --git a/internal/releaser/gitlab/gitlab.go b/internal/releaser/gitlab/gitlab.go index f521761..131acaa 100644 --- a/internal/releaser/gitlab/gitlab.go +++ b/internal/releaser/gitlab/gitlab.go @@ -98,7 +98,11 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC // CreateRelease creates release on remote 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.log.Infof("create release with version %s", tag) url := fmt.Sprintf("%s/projects/%s/releases", g.apiURL, util.PathEscape(g.config.Repo)) diff --git a/pkg/config/config.go b/pkg/config/config.go index 008c176..091a7ff 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -9,6 +9,10 @@ import ( "gopkg.in/yaml.v2" ) +const ( + DefaultTagPrefix = "v" +) + // ChangelogConfig struct type ChangelogConfig struct { PrintAll bool `yaml:"printAll,omitempty"` @@ -44,6 +48,7 @@ type GitHubProvider struct { User string `yaml:"user"` CustomURL string `yaml:"customUrl,omitempty"` AccessToken string + TagPrefix *string `yaml:"tagPrefix,omitempty"` } // GitLabProvider struct @@ -51,6 +56,7 @@ type GitLabProvider struct { Repo string `yaml:"repo"` CustomURL string `yaml:"customUrl,omitempty"` AccessToken string + TagPrefix *string `yaml:"tagPrefix,omitempty"` } // GitProvider struct @@ -59,6 +65,7 @@ type GitProvider struct { Username string `yaml:"user"` Auth string `yaml:"auth"` SSH bool `yaml:"ssh"` + TagPrefix *string `yaml:"tagPrefix,omitempty"` } // Hooks struct