Skip to content

Commit

Permalink
Issue #111: Alibaba DragonWell actions adds source (#1321)
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 authored Oct 13, 2023
1 parent 768d7ae commit 9080f57
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions actions/alibaba-dragonwell-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func main() {
globRegex = regexp.MustCompile(".+")
}

// github repo under the `alibaba` org to watch
r, ok := inputs["repository"]
// github repo under the `dragonwell-project` org to watch
repo, ok := inputs["repository"]
if !ok {
panic(fmt.Errorf("repository must be specified"))
}
Expand All @@ -60,11 +60,12 @@ func main() {

tagRegex := regexp.MustCompile(`dragonwell-.*_jdk[-]?(.*)-ga`)
versions := actions.Versions{}
sources := make(map[string]string)
opt := &github.ListOptions{PerPage: 100}
for {
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "alibaba", r, opt)
rel, rsp, err := gh.Repositories.ListReleases(context.Background(), "dragonwell-project", repo, opt)
if err != nil {
panic(fmt.Errorf("unable to list existing releases for alibaba/%s\n%w", r, err))
panic(fmt.Errorf("unable to list existing releases for dragonwell-project/%s\n%w", repo, err))
}

for _, r := range rel {
Expand All @@ -76,6 +77,7 @@ func main() {
version = fmt.Sprintf("8.0.%s", strings.TrimLeft(version, "8u"))
}
versions[version] = *a.BrowserDownloadURL
sources[version] = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s.tar.gz", "dragonwell-project", repo, *r.TagName)
break
}
}
Expand All @@ -93,7 +95,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 9080f57

Please sign in to comment.