Skip to content

Commit

Permalink
Merge pull request #3063 from ActiveState/mitchell/dx-2497
Browse files Browse the repository at this point in the history
Attempt to determine version from filename to publish.
  • Loading branch information
mitchell-as authored Jan 30, 2024
2 parents ef247f9 + 4d67494 commit da441eb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/runners/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package publish
import (
"net/http"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -249,12 +250,17 @@ func (r *Runner) Run(params *Params) error {
return nil
}

var versionRegexp = regexp.MustCompile(`\d+\.\d+(\.\d+)?`)

func prepareRequestFromParams(r *request.PublishVariables, params *Params, isRevision bool) error {
if params.Version != "" {
r.Version = params.Version
}
if r.Version == "" {
r.Version = "0.0.1"
if matches := versionRegexp.FindAllString(params.Filepath, 1); matches != nil {
r.Version = matches[0]
}
}

if params.Description != "" {
Expand Down

0 comments on commit da441eb

Please sign in to comment.