Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ To use this plugin you need to include the following block in your
| auth_private_key | | The path to an SSH private key file. |
| git_path | . | The path to the Git repository. |
| push_options | | The push options for the git tag push. |
| tag_prefix | | The tag prefix for the versions. |

### Authentication

Expand Down
11 changes: 8 additions & 3 deletions pkg/provider/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Repository struct {
auth transport.AuthMethod
repo *git.Repository
pushOptions map[string]string
prefix string
}

func (repo *Repository) Init(config map[string]string) error {
Expand Down Expand Up @@ -78,6 +79,10 @@ func (repo *Repository) Init(config map[string]string) error {
}
}

if config["tag_prefix"] != "" {
repo.prefix = config["tag_prefix"]
}

gitPath := config["git_path"]
if gitPath == "" {
gitPath = "."
Expand Down Expand Up @@ -149,10 +154,10 @@ func (repo *Repository) GetReleases(rawRe string) ([]*semrel.Release, error) {

err = tags.ForEach(func(reference *plumbing.Reference) error {
ref := reference.Name().String()
if !strings.HasPrefix(ref, "refs/tags/") {
if !strings.HasPrefix(ref, "refs/tags/"+repo.prefix) {
return nil
}
tag := strings.TrimPrefix(ref, "refs/tags/")
tag := strings.TrimPrefix(ref, "refs/tags/"+repo.prefix)
if rawRe != "" && !re.MatchString(tag) {
return nil
}
Expand Down Expand Up @@ -194,7 +199,7 @@ func (repo *Repository) CreateRelease(release *provider.CreateReleaseConfig) err
}
hash = resolvedRef.Hash()
}
tag := fmt.Sprintf("v%s", release.NewVersion)
tag := fmt.Sprintf("%sv%s", repo.prefix, release.NewVersion)
_, err := repo.repo.CreateTag(tag, hash, &git.CreateTagOptions{
Message: release.Changelog,
Tagger: &object.Signature{
Expand Down