Skip to content

Commit

Permalink
Issue #111: Amazon Corretto actions adds source
Browse files Browse the repository at this point in the history
* using the Github API TarballURL; source code that matches what was used to build the jdk
  • Loading branch information
anthonydahanne committed Oct 13, 2023
1 parent 106f03f commit 15ee4af
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions actions/amazon-corretto-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
func main() {
inputs := actions.NewInputs()

r, ok := inputs["repository"]
repo, ok := inputs["repository"]
if !ok {
panic(fmt.Errorf("repository must be specified"))
}
Expand All @@ -56,14 +56,15 @@ func main() {
gh := github.NewClient(c)

versions := make(actions.Versions)
sources := make(map[string]string)

md := regexp.MustCompile(`(?U)\[(.+)]\((.+)\)`)

opt := &github.ListOptions{PerPage: 100}
for {
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "corretto", r, opt)
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "corretto", repo, opt)
if err != nil {
panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", "corretto", r, err))
panic(fmt.Errorf("unable to list existing releases for %s/%s\n%w", "corretto", repo, err))
}

for _, r := range rel {
Expand All @@ -86,6 +87,7 @@ func main() {
}

versions[s] = p[2]
sources[s] = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s.tar.gz", "corretto", repo, *r.TagName)
}
}
}
Expand All @@ -103,7 +105,12 @@ func main() {
panic(fmt.Errorf("unable to get latest version\n%w", err))
}

outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil)
latestSource := actions.Outputs{}
if sources != nil {
latestSource["source"] = sources[latestVersion.Original()]
}

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

0 comments on commit 15ee4af

Please sign in to comment.