Skip to content

Commit

Permalink
updates actions with source output, fixes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed Oct 10, 2023
1 parent 106f03f commit 3d09840
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 23 deletions.
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])
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()
}
}
16 changes: 14 additions & 2 deletions actions/gradle-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ 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 {
}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
16 changes: 14 additions & 2 deletions 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,9 +57,19 @@ func main() {
opt.Page = r.NextPage
}

if o, err := versions.GetLatest(inputs); err != nil {
latestVersion, err := versions.GetLatestVersion(inputs)
if err != nil {
panic(err)
} else {
}
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()
}
}
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
2 changes: 1 addition & 1 deletion actions/skywalking-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3d09840

Please sign in to comment.