Skip to content

Commit

Permalink
adds source uri/sha fields support
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed Sep 20, 2023
1 parent 363abcb commit fc1848a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18 as build-stage
FROM golang:1.20.8-bullseye as build-stage

RUN apt-get update && apt-get install -y --no-install-recommends upx

Expand Down
7 changes: 7 additions & 0 deletions actions/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ func NewOutputs(uri string, latestVersion *semver.Version, additionalOutputs Out
}

for k, v := range additionalOutputs {
if k == "source" {
sourceSha256, err := SHA256FromURI(v, mods...)
if err != nil {
return nil, fmt.Errorf("unable to calculate source sha256\n%w", err)
}
outputs["source_sha256"] = sourceSha256
}
outputs[k] = v
}

Expand Down
9 changes: 8 additions & 1 deletion actions/tomee-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func main() {
c := colly.NewCollector()

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

c.OnHTML("a[href]", func(element *colly.HTMLElement) {
if p := TomeeVersionPattern.FindStringSubmatch(element.Attr("href")); p != nil {
if major == "" || major == p[1] {
Expand All @@ -59,6 +61,7 @@ func main() {
}

versions[verKey] = fmt.Sprintf("%s/tomee-%[2]s/apache-tomee-%[2]s-%s.tar.gz", uri, verVal, dist)
sources[verKey] = fmt.Sprintf("%s/tomee-%[2]s/tomee-project-%[2]s-source-release.zip", uri, verVal, dist)
}
}
})
Expand All @@ -71,8 +74,12 @@ func main() {
if err != nil {
panic(err)
}
latestSource := actions.Outputs{}
if sources != nil {
latestSource["source"] = sources[latestVersion.Original()]
}

o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil)
o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource)
if err != nil {
panic(err)
}
Expand Down
2 changes: 2 additions & 0 deletions octo/buildpack_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func ContributeBuildpackDependencies(descriptor Descriptor) ([]Contribution, err
"CPE_PATTERN": d.CPEPattern,
"PURL": "${{ steps.dependency.outputs.purl }}",
"PURL_PATTERN": d.PURLPattern,
"SOURCE_URI": "${{ steps.dependency.outputs.source }}",
"SOURCE_SHA256": "${{ steps.dependency.outputs.source_sha256 }}",
},
}, {
Uses: "peter-evans/create-pull-request@v5",
Expand Down
2 changes: 1 addition & 1 deletion octo/statik/statik.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion octo/update-buildpack-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ update-buildpack-dependency \
--purl-pattern "${PURL_PATTERN:-}" \
--purl "${PURL:-}" \
--uri "${URI}" \
--sha256 "${SHA256}"
--sha256 "${SHA256}" \
--source "${SOURCE_URI}" \
--source-sha256 "${SOURCE_SHA256}"

git add buildpack.toml
git checkout -- .
Expand Down

0 comments on commit fc1848a

Please sign in to comment.