Skip to content

Commit

Permalink
fix(version): log last release by tag name alphabetically instead of …
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
qdm12 committed Aug 9, 2024
1 parent ecbfc02 commit 09c47c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"sort"
"time"

"github.com/qdm12/gluetun/internal/models"
Expand Down Expand Up @@ -49,13 +50,17 @@ func getLatestRelease(ctx context.Context, client *http.Client) (tagName, name s
if err != nil {
return "", "", time, err
}
// Sort releases by tag names (semver)
sort.Slice(releases, func(i, j int) bool {
return releases[i].TagName > releases[j].TagName
})
for _, release := range releases {
if release.Prerelease {
continue
}
return release.TagName, release.Name, release.PublishedAt, nil
}
return "", "", time, errReleaseNotFound
return "", "", time, fmt.Errorf("%w", errReleaseNotFound)
}

var errCommitNotFound = errors.New("commit not found")
Expand Down

0 comments on commit 09c47c7

Please sign in to comment.