Cannot isolate asset from releases with multiple artifacts
fredbi opened this issue · comments
When building a release with multiple artifacts (e.g. with goreleaser),
I found out that the self update cannot figure out which is the correct one.
As a matter of facts, this line tells that the first asset found with matching release, arch etc is
selected:
go-github-selfupdate/selfupdate/detect.go
Line 52 in 80762b8
I am proposing a fix here along the following lines:
- add a
type Option func(*settings)
to capture some specific settings - add a
type settings{filters: []*regexp.Regexp}
to capture specifically a filter on assets (might be extended later on) - add an option functor like
func
AssetFilter(filter string) Option` to add some filtering regexp (note: invalid regexp panics...) - supplement the line above by a check on optional filters and select the first asset which matches any of the provided filters. If no filter is provided, keep the existing behavior
- most public API calls (not all of them, though) are amended with a
opt ...Option
optional parameter, so we may pass the filter down tofindAssetFromRelease
Would that approach look acceptable?