Skip to content

Commit

Permalink
Issue #111: Alibaba DragonWell 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 6, 2023
1 parent 106f03f commit 53670c9
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,7 +46,7 @@ func main() {
globRegex = regexp.MustCompile(".+")
}

// github repo under the `alibaba` org to watch
// github repo under the `dragonwell-project` org to watch
r, ok := inputs["repository"]
if !ok {
panic(fmt.Errorf("repository must be specified"))
Expand All @@ -60,18 +60,20 @@ 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", r, 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", r, err))
}

for _, r := range rel {
if tag := tagRegex.FindStringSubmatch(*r.TagName); tag != nil {
version := tag[1]
sources[version] = *r.TarballURL
for _, a := range r.Assets {
if globRegex.MatchString(*a.Name) {
version := tag[1]
if strings.HasPrefix(version, "8u") {
version = fmt.Sprintf("8.0.%s", strings.TrimLeft(version, "8u"))
}
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 53670c9

Please sign in to comment.