Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any prefix to semver tag #3

Merged
merged 1 commit into from
Dec 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [Unreleased]
### Added
- Allow any prefix to semver tag

## [1.0.0] - 2019-10-01
- First stable release.

Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func GetDetails(r *remote.Remote) error {
}

// remove v from version tag.
name := strings.Trim(tag, "v")
var re = regexp.MustCompile(".*([0-9]+.[0-9]+.[0-9]+)")
name := re.ReplaceAllString(tag, "$1")

r.Owner = repoName["owner"]
r.Repository = repoName["name"]
Expand Down Expand Up @@ -66,10 +67,10 @@ func getVersionTag() (string, error) {
return "", errors.New("environmental variable GITHUB_REF not defined")
}

regex := regexp.MustCompile("refs/tags/v?[0-9]+.[0-9]+.[0-9]+")
regex := regexp.MustCompile("refs/tags/.*[0-9]+.[0-9]+.[0-9]+")
if regex.MatchString(o) {
return strings.Split(o, "/")[2], nil
}

return "", errors.New("no matching tags found. expected to match regex 'v?[0-9]+.[0-9]+.[0-9]+'")
return "", errors.New("no matching tags found. expected to match regex '.*[0-9]+.[0-9]+.[0-9]+'")
}