Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds source uri/sha fields support #1292

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
anthonydahanne marked this conversation as resolved.
Show resolved Hide resolved
}
}
})
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
Loading