-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (43 loc) · 907 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"bufio"
"fmt"
"os"
log "github.com/cantara/bragi/sbragi"
"github.com/cantara/buri/version/filter"
"github.com/cantara/buri/version/release"
"golang.org/x/exp/slog"
)
func main() {
n, err := log.NewLogger(slog.HandlerOptions{
AddSource: true,
Level: log.LevelWarning,
}.NewTextHandler(os.Stderr))
if err != nil {
log.WithError(err).Fatal("while creating error logger")
return
}
n.SetDefault()
var newest *release.Version
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
v, err := release.Parse(scanner.Text())
if err != nil {
log.WithError(err).Warning("tag was not a release version")
continue
}
if newest == nil {
newest = &v
continue
}
if newest.IsStrictlySemanticNewer(filter.AllReleases, v) {
newest = &v
continue
}
}
if newest == nil {
fmt.Println("v0.0.0")
return
}
fmt.Println(newest.String())
}