ci: support pre-release versions, sort ebuilds
This commit is contained in:
parent
51f15f52a4
commit
0501d982b5
6 changed files with 39 additions and 2 deletions
|
@ -3,6 +3,7 @@ module github.com/jaredallard/overlay/.tools
|
|||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/blang/semver/v4 v4.0.0
|
||||
github.com/charmbracelet/log v0.3.1
|
||||
github.com/docker/docker v25.0.3+incompatible
|
||||
github.com/egym-playground/go-prefix-writer v0.0.0-20180609083313-7326ea162eca
|
||||
|
|
|
@ -4,6 +4,8 @@ github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+q
|
|||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
|
||||
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
||||
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
|
||||
|
|
|
@ -146,4 +146,8 @@ type APTOptions struct {
|
|||
|
||||
// Package is the name of the package to watch versions for.
|
||||
Package string `yaml:"package"`
|
||||
|
||||
// StripRelease is a boolean that denotes if extra release information
|
||||
// (in the context of a semver) should be stripped. Defaults to true.
|
||||
StripRelease *bool `yaml:"strip_release"`
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -81,7 +82,8 @@ func Parse(path string) (*Ebuild, error) {
|
|||
return parse(path, b)
|
||||
}
|
||||
|
||||
// ParseDir parses all ebuilds in the provided directory and returns them.
|
||||
// ParseDir parses all ebuilds in the provided directory and returns
|
||||
// them. Returns them in descending order of the ebuild's version.
|
||||
func ParseDir(path string) ([]*Ebuild, error) {
|
||||
var ebuilds []*Ebuild
|
||||
|
||||
|
@ -103,6 +105,11 @@ func ParseDir(path string) ([]*Ebuild, error) {
|
|||
ebuilds = append(ebuilds, ebuild)
|
||||
}
|
||||
|
||||
// Sort based on the version.
|
||||
sort.Slice(ebuilds, func(i, j int) bool {
|
||||
return ebuilds[i].Version > ebuilds[j].Version
|
||||
})
|
||||
|
||||
return ebuilds, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package updater
|
||||
|
||||
import (
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/jaredallard/overlay/.tools/internal/config"
|
||||
"github.com/jaredallard/overlay/.tools/internal/resolver/apt"
|
||||
)
|
||||
|
@ -23,8 +24,25 @@ import (
|
|||
// getAPTVersion returns the latest version of an APT package based on
|
||||
// the config provided.
|
||||
func getAPTVersion(ce *config.Ebuild) (string, error) {
|
||||
return apt.GetPackageVersion(apt.Lookup{
|
||||
v, err := apt.GetPackageVersion(apt.Lookup{
|
||||
SourcesEntry: ce.APTOptions.Repository,
|
||||
Package: ce.APTOptions.Package,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Remove build and pre-release versions if we're stripping them.
|
||||
if ce.APTOptions.StripRelease == nil || *ce.APTOptions.StripRelease {
|
||||
sv, err := semver.ParseTolerant(v)
|
||||
if err != nil {
|
||||
// Leave it as is.
|
||||
return v, nil
|
||||
}
|
||||
sv.Pre = nil
|
||||
sv.Build = nil
|
||||
return sv.String(), nil
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ app-admin/1password:
|
|||
options:
|
||||
repository: "deb https://downloads.1password.com/linux/debian/amd64 stable main"
|
||||
package: 1password
|
||||
app-admin/op-cli-bin:
|
||||
resolver: apt
|
||||
options:
|
||||
repository: "deb https://downloads.1password.com/linux/debian/amd64 stable main"
|
||||
package: 1password-cli
|
||||
app-arch/7-zip:
|
||||
resolver: git
|
||||
options:
|
||||
|
|
Loading…
Add table
Reference in a new issue