diff --git a/actions/github-release-dependency/main.go b/actions/github-release-dependency/main.go index b210ce74..8a8ee2f0 100644 --- a/actions/github-release-dependency/main.go +++ b/actions/github-release-dependency/main.go @@ -38,7 +38,7 @@ func main() { panic(fmt.Errorf("owner must be specified")) } - r, ok := inputs["repository"] + repo, ok := inputs["repository"] if !ok { panic(fmt.Errorf("repository must be specified")) } @@ -74,6 +74,8 @@ func main() { gh := github.NewClient(c) versions := make(actions.Versions) + originalTagName := make(map[string]string) + sources := make(map[string]string) re, err := regexp.Compile(t) if err != nil { @@ -83,9 +85,9 @@ func main() { var releases []*github.RepositoryRelease opt := &github.ListOptions{PerPage: 100} for { - rel, rsp, err := gh.Repositories.ListReleases(context.Background(), o, r, opt) + rel, rsp, err := gh.Repositories.ListReleases(context.Background(), o, repo, opt) if err != nil { - panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", o, r, err)) + panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", o, repo, err)) } for _, r := range rel { @@ -98,6 +100,7 @@ func main() { if err != nil { panic(err) } + originalTagName[n] = *r.TagName r.TagName = github.String(n) releases = append(releases, r) @@ -122,14 +125,27 @@ func main() { 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 } } } - if o, err := versions.GetLatest(inputs); err != nil { - panic(err) + latestVersion, err := versions.GetLatestVersion(inputs) + 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()] + } + + + url := versions[latestVersion.Original()] + outputs, err := actions.NewOutputs(url, latestVersion, latestSource) + if err != nil { + panic(fmt.Errorf("unable to create outputs\n%w", err)) } else { - o.Write() + outputs.Write() } } diff --git a/actions/gradle-dependency/main.go b/actions/gradle-dependency/main.go index df5c6fac..6b2e05b8 100644 --- a/actions/gradle-dependency/main.go +++ b/actions/gradle-dependency/main.go @@ -45,11 +45,23 @@ func main() { } versions := make(actions.Versions) + sources := make(map[string]string) for _, v := range raw.FinalReleases { versions[v.Version] = fmt.Sprintf("https://downloads.gradle.org/distributions/gradle-%s-bin.zip", v.Version) + sources[v.Version] = fmt.Sprintf("https://downloads.gradle.org/distributions/gradle-%s-src.zip", v.Version) } - if o, err := versions.GetLatest(inputs); err != nil { + latestVersion, err := versions.GetLatestVersion(inputs) + if err != nil { + panic(err) + } + latestSource := actions.Outputs{} + if len(sources) != 0{ + latestSource["source"] = sources[latestVersion.Original()] + } + + o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource) + if err != nil { panic(err) } else { o.Write() diff --git a/actions/ibm-semeru-dependency/main.go b/actions/ibm-semeru-dependency/main.go index 81f0a256..35a567a0 100644 --- a/actions/ibm-semeru-dependency/main.go +++ b/actions/ibm-semeru-dependency/main.go @@ -38,7 +38,7 @@ func main() { panic(fmt.Errorf("owner must be specified")) } - r, ok := inputs["repository"] + repo, ok := inputs["repository"] if !ok { panic(fmt.Errorf("repository must be specified")) } @@ -68,6 +68,7 @@ func main() { gh := github.NewClient(c) versions := make(actions.Versions) + sources := make(map[string]string) re, err := regexp.Compile(t) if err != nil { @@ -76,9 +77,9 @@ func main() { opt := &github.ListOptions{PerPage: 100} for { - rel, rsp, err := gh.Repositories.ListReleases(context.Background(), o, r, opt) + rel, rsp, err := gh.Repositories.ListReleases(context.Background(), o, repo, opt) if err != nil { - panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", o, r, err)) + panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", o, repo, err)) } for _, r := range rel { @@ -95,8 +96,9 @@ func main() { // Decode JSON so we can extract 'version.semver' json := getReleaseJSON(versionJSON) // Record semver against the asset's tar.gz URL - versions[strings.ReplaceAll(json.VersionData.Semver, "+", "-")] = *a.BrowserDownloadURL - + v := strings.ReplaceAll(json.VersionData.Semver, "+", "-") + versions[v] = *a.BrowserDownloadURL + sources[v] = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s.tar.gz", o, repo, *r.TagName) break } } @@ -113,9 +115,14 @@ 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()] + } + url := versions[latestVersion.Original()] - outputs, err := actions.NewOutputs(url, latestVersion, nil) + outputs, err := actions.NewOutputs(url, latestVersion, latestSource) if err != nil { panic(fmt.Errorf("unable to create outputs\n%w", err)) } diff --git a/actions/leiningen-dependency/main.go b/actions/leiningen-dependency/main.go index 6eff2b11..dbb2904e 100644 --- a/actions/leiningen-dependency/main.go +++ b/actions/leiningen-dependency/main.go @@ -37,6 +37,7 @@ func main() { gh := github.NewClient(c) versions := make(actions.Versions) + sources := make(map[string]string) opt := &github.ListOptions{PerPage: 100} for { @@ -47,6 +48,7 @@ func main() { for _, r := range rel { versions[*r.TagName] = fmt.Sprintf("https://raw.githubusercontent.com/technomancy/leiningen/%s/bin/lein", *r.TagName) + sources[*r.TagName] = fmt.Sprintf("https://github.com/technomancy/leiningen/archive/refs/tags/%s.tar.gz", *r.TagName) } if r.NextPage == 0 { @@ -55,7 +57,17 @@ func main() { opt.Page = r.NextPage } - if o, err := versions.GetLatest(inputs); err != nil { + latestVersion, err := versions.GetLatestVersion(inputs) + if err != nil { + panic(err) + } + latestSource := actions.Outputs{} + if len(sources) != 0{ + latestSource["source"] = sources[latestVersion.Original()] + } + + o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource) + if err != nil { panic(err) } else { o.Write() diff --git a/actions/liberty-dependency/main.go b/actions/liberty-dependency/main.go index a44b1e93..589197c8 100644 --- a/actions/liberty-dependency/main.go +++ b/actions/liberty-dependency/main.go @@ -38,6 +38,10 @@ func main() { if !ok { panic(fmt.Errorf("group_id must be specified")) } + source_available := false + if strings.Contains(g, "openliberty"){ + source_available = true + } a, ok := inputs["artifact_id"] if !ok { @@ -63,9 +67,12 @@ func main() { originalVersions := map[string]string{} versions := make(actions.Versions) + sources := make(map[string]string) + for _, v := range raw.Versioning.Versions { w := fmt.Sprintf("%s/%s/%s/%s", u, strings.ReplaceAll(g, ".", "/"), a, v) w = fmt.Sprintf("%s/%s-%s", w, a, v) + if s, ok := inputs["classifier"]; ok { w = fmt.Sprintf("%s-%s", w, s) } @@ -79,7 +86,9 @@ func main() { if err != nil { panic(err) } - + if source_available { + sources[v] = fmt.Sprintf("https://github.com/OpenLiberty/open-liberty/archive/refs/tags/gm-%s.tar.gz", v) + } originalVersions[n] = v versions[n] = w } @@ -88,8 +97,12 @@ 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[originalVersions[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)) } diff --git a/actions/maven-dependency/main.go b/actions/maven-dependency/main.go index d0eb20ec..ad55f14c 100644 --- a/actions/maven-dependency/main.go +++ b/actions/maven-dependency/main.go @@ -107,7 +107,7 @@ func main() { panic(err) } latestSource := actions.Outputs{} - if sources != nil { + if len(sources) != 0{ latestSource["source"] = sources[latestVersion.Original()] } diff --git a/actions/new-relic-dependency/main.go b/actions/new-relic-dependency/main.go index 971be5e4..c654e482 100644 --- a/actions/new-relic-dependency/main.go +++ b/actions/new-relic-dependency/main.go @@ -84,7 +84,7 @@ func main() { panic(err) } latestSource := actions.Outputs{} - if sources != nil { + if len(sources) != 0{ latestSource["source"] = sources[latestVersion.Original()] } diff --git a/actions/npm-dependency/main.go b/actions/npm-dependency/main.go index 70efc863..de30cc71 100644 --- a/actions/npm-dependency/main.go +++ b/actions/npm-dependency/main.go @@ -58,13 +58,25 @@ func main() { } versions := make(actions.Versions) + sources := make(map[string]string) for k, v := range raw.Versions { if p := versionPattern.MatchString(k); p { versions[k] = v.Dist.Tarball + sources[k] = v.Dist.Tarball } } - if o, err := versions.GetLatest(inputs); err != nil { + latestVersion, err := versions.GetLatestVersion(inputs) + if err != nil { + panic(err) + } + latestSource := actions.Outputs{} + if len(sources) != 0{ + latestSource["source"] = sources[latestVersion.Original()] + } + + o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource) + if err != nil { panic(err) } else { o.Write() diff --git a/actions/skywalking-dependency/main.go b/actions/skywalking-dependency/main.go index 22fb57e9..84d501cc 100644 --- a/actions/skywalking-dependency/main.go +++ b/actions/skywalking-dependency/main.go @@ -28,7 +28,7 @@ import ( func main() { inputs := actions.NewInputs() - uri := "https://archive.apache.org/dist/skywalking/java-agent/" + uri := "https://archive.apache.org/dist/skywalking/java-agent" c := colly.NewCollector() @@ -54,7 +54,7 @@ func main() { panic(err) } latestSource := actions.Outputs{} - if sources != nil { + if len(sources) != 0{ latestSource["source"] = sources[latestVersion.Original()] } diff --git a/actions/tomcat-dependency/main.go b/actions/tomcat-dependency/main.go index 691477f7..91979dd9 100644 --- a/actions/tomcat-dependency/main.go +++ b/actions/tomcat-dependency/main.go @@ -63,7 +63,7 @@ func main() { panic(err) } latestSource := actions.Outputs{} - if sources != nil { + if len(sources) != 0{ latestSource["source"] = sources[latestVersion.Original()] } diff --git a/actions/tomee-dependency/main.go b/actions/tomee-dependency/main.go index 4c6ade68..7df1ec37 100644 --- a/actions/tomee-dependency/main.go +++ b/actions/tomee-dependency/main.go @@ -75,7 +75,7 @@ func main() { panic(err) } latestSource := actions.Outputs{} - if sources != nil { + if len(sources) != 0{ latestSource["source"] = sources[latestVersion.Original()] }