Documentation
¶
Overview ¶
Package semver provides a library for resolving semantic version constraints against GitHub repository tags and releases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxSatisfying ¶
func MaxSatisfying(ctx context.Context, owner, repo, constraint string, opts *Options) (string, error)
MaxSatisfying returns the highest version that satisfies the given constraint for the specified GitHub repository.
The constraint should be a valid semantic version constraint as defined by https://github.com/Masterminds/semver.
Example:
version, err := semver.MaxSatisfying(ctx, "golang", "go", "~1.21.0", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(version) // e.g., "go1.21.5"
func MaxSatisfyingWithToken ¶
func MaxSatisfyingWithToken(ctx context.Context, owner, repo, constraint, token string) (string, error)
MaxSatisfyingWithToken is a convenience function that creates a GitHub client with the provided token and resolves the version constraint.
This is equivalent to calling MaxSatisfying with Options{Token: token}.
Types ¶
type Options ¶
type Options struct {
// Token is the GitHub personal access token.
// If empty, it will try to get token from environment variables or keyring.
Token string
// IncludePrerelease includes prerelease versions in the resolution.
IncludePrerelease bool
// IncludeDraft includes draft releases in the resolution.
IncludeDraft bool
// IncludeTags includes git tags in addition to releases.
// By default, only GitHub releases are considered.
IncludeTags bool
// GitHubClient allows using a custom GitHub client.
// If nil, a default client will be created.
GitHubClient github.Client
}
Options configures the version resolution behavior.
Click to show internal directories.
Click to hide internal directories.