Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates actions with source output, fixes bug #1325

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions actions/github-release-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -98,6 +100,7 @@ func main() {
if err != nil {
panic(err)
}
originalTagName[n] = *r.TagName
r.TagName = github.String(n)

releases = append(releases, r)
Expand All @@ -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])
anthonydahanne marked this conversation as resolved.
Show resolved Hide resolved
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()
}
}
14 changes: 13 additions & 1 deletion actions/gradle-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 13 additions & 6 deletions actions/ibm-semeru-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
}
Expand All @@ -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))
}
Expand Down
14 changes: 13 additions & 1 deletion actions/leiningen-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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()
Expand Down
17 changes: 15 additions & 2 deletions actions/liberty-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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
}
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion actions/maven-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func main() {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
}

Expand Down
2 changes: 1 addition & 1 deletion actions/new-relic-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func main() {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
}

Expand Down
14 changes: 13 additions & 1 deletion actions/npm-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
anthonydahanne marked this conversation as resolved.
Show resolved Hide resolved
}
}

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()
Expand Down
4 changes: 2 additions & 2 deletions actions/skywalking-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -54,7 +54,7 @@ func main() {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
}

Expand Down
2 changes: 1 addition & 1 deletion actions/tomcat-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
}

Expand Down
2 changes: 1 addition & 1 deletion actions/tomee-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
if len(sources) != 0{
latestSource["source"] = sources[latestVersion.Original()]
}

Expand Down
Loading