From bce02fc06c5b1e7707e6d65173386c409247f3ce Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Tue, 26 Sep 2023 15:31:16 -0400 Subject: [PATCH] Issue #111: Adoptium actions adds source --- actions/adoptium-dependency/main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/actions/adoptium-dependency/main.go b/actions/adoptium-dependency/main.go index d5d7717a..5ffe918d 100644 --- a/actions/adoptium-dependency/main.go +++ b/actions/adoptium-dependency/main.go @@ -70,16 +70,24 @@ func main() { } versions := make(actions.Versions) + sources := make(map[string]string) + for _, r := range raw { - versions[strings.ReplaceAll(r.VersionData.Semver, "+", "-")] = r.Binaries[0].Package.Link + version := strings.ReplaceAll(r.VersionData.Semver, "+", "-") + versions[version] = r.Binaries[0].Package.Link + sources[version] = r.Source.Link } latestVersion, err := versions.GetLatestVersion(inputs) if err != nil { panic(fmt.Errorf("unable to get latest version\n%w", err)) } + latestSource := actions.Outputs{} + if sources != nil { + latestSource["source"] = sources[latestVersion.Original()] + } - outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil) + outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource) if err != nil { panic(fmt.Errorf("unable to create outputs\n%w", err)) } @@ -98,6 +106,7 @@ func main() { type Asset struct { Binaries []Binary VersionData VersionData `json:"version_data"` + Source Source } type Binary struct { @@ -108,6 +117,10 @@ type Package struct { Link string } +type Source struct { + Link string +} + type VersionData struct { Semver string }