Skip to content

Commit

Permalink
Add support for arm64 archives
Browse files Browse the repository at this point in the history
* with a new input, ARM_GLOB
  • Loading branch information
anthonydahanne committed Oct 17, 2023
1 parent a8e9917 commit f3929a9
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions actions/github-release-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func main() {
g = regexp.MustCompile(".+")
}

var armG *regexp.Regexp
if s, ok := inputs["arm_glob"]; ok {
armG, err = regexp.Compile(s)
if err != nil {
panic(fmt.Errorf("unable to compile %s as a regexp\n%w", s, err))
}
}

t := `v?([^v].*)`
if s, ok := inputs["tag_filter"]; ok {
t = s
Expand Down Expand Up @@ -121,12 +129,14 @@ func main() {
releases = releases[len(releases)-1:]
}

armVersions := make(actions.Versions)
for _, r := range releases {
for _, a := range r.Assets {
if g.MatchString(*a.Name) {
versions[*r.TagName] = *a.BrowserDownloadURL
sources[*r.TagName] = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s.tar.gz", o, repo, originalTagName[*r.TagName])
break
} else if armG != nil && armG.MatchString(*a.Name) {
armVersions[*r.TagName] = *a.BrowserDownloadURL
}
}
}
Expand All @@ -135,14 +145,16 @@ func main() {
if err != nil {
panic(fmt.Errorf("unable to get latest version\n%w", err))
}
latestSource := actions.Outputs{}
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
additionalOutputs := actions.Outputs{}
if len(sources) != 0 {
additionalOutputs["source"] = sources[latestVersion.Original()]
}
if len(armVersions) != 0 {
additionalOutputs["arm64-uri"] = armVersions[latestVersion.Original()]
}


url := versions[latestVersion.Original()]
outputs, err := actions.NewOutputs(url, latestVersion, latestSource)
outputs, err := actions.NewOutputs(url, latestVersion, additionalOutputs)
if err != nil {
panic(fmt.Errorf("unable to create outputs\n%w", err))
} else {
Expand Down

0 comments on commit f3929a9

Please sign in to comment.