From a6c30a0e0e7395c669f47762fea230fd0b0f4da2 Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Mon, 18 Apr 2022 16:49:36 -0400 Subject: [PATCH] Add version to compute artifact action The compute artifact action needs the version. The workflows that use it, keep the version as a separate value not part of the package URI. This allows it to be passed in as a separate parameter, 'version'. Signed-off-by: Daniel Mikusa --- README.md | 28 ++++++++++++++++++-- actions/compute-artifact-description/main.go | 13 ++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d992664c..8f998aef 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The Pipeline Builder is a collection of tools related to GitHub Actions and othe - [CA APM Dependency](#ca-apm-dependency) - [CF Java Index Dependency](#cf-java-index-dependency) - [Clojure Tools Dependency](#clojure-tools-dependency) + - [Compute Artifact Dependencies](#compute-artifact-dependencies) - [Draft Release](#draft-release) - [Foojay Dependency](#foojay-dependency) - [GCS Dependency](#gcs-dependency) @@ -384,6 +385,7 @@ with: ``` ### Clojure Tools Dependency + The Clojure Tools Dependency watches [Clojure Tools repositories](https://github.com/clojure/clojure-tools) for new versions. It then filters based on the [stable.properties](https://raw.githubusercontent.com/clojure/brew-install/%s/stable.properties) file in their brew tap repo, allowing it to pick the most recent stable version. ```yaml @@ -392,6 +394,28 @@ with: token: ${{ secrets.JAVA_GITHUB_TOKEN }} ``` +### Compute Artifact Dependencies + +The Compute Artifact Dependencies takes a buildpack image and produces the list of included dependencies. It's used for generating release notes. If the image is a composite buildpack, then it will recursively load all of the referenced buildpacks, pulling metadata directly from Github, and give a compete, sorted and deduplicated list of dependencies. + +A Github token is strongly recommended. This is for fetching information from Github, and without it you might get rate limited. It is required for private repositories. + +The `package` and `version` entries are required. They are required to indiciate the specific buildpack that will be described. + +A mapper will add additional permutations of Github project URIs to try. For example, if you have an image URI of `gcr.io/foo/bar:1.2.3` but the Github project is at `github.com/org/foo-bar` then you can add a mapper of `|foo\/bar|org/foo-bar|` to have `compute-artifact-dependencies` try both. You can specify as many mappers as you want, with each mapper generating a new URI for `compute-artifact-dependencies` to try. It will stop when it hits the first URL that successfully pulls back the `buildpack.toml` file. + +The output is `artifact-reference-description`, which can be referenced by other jobs. + +```yaml +uses: docker://ghcr.io/paketo-buildpacks/actions/compute-artifact-description:main +with: + github_token: ${{ secrets.JAVA_GITHUB_TOKEN }} + package: "gcr.io/paketo-buildpacks/java" + version: "1.2.3" + mapper_1: '|tanzu-buildpacks|paketo-buildpacks|' + mapper_2: '|tanzu-buildpacks\/|pivotal-cf/tanzu-|' +``` + ### Draft Release The `draft-release` action is used to augment release notes generated by the `release-drafter` action. The `release-drafter` pulls in notes based on PR changes. The `draft-release` action is what augments those with all of the buildpack specific information. For example, dependencies included or order groups. @@ -404,8 +428,8 @@ A mapper will add additional permutations of Github project URIs to try. For exa uses: docker://ghcr.io/paketo-buildpacks/actions/draft-release:main with: github_token: ${{ secrets.JAVA_GITHUB_TOKEN }} - mapper_1: '|tanzu-buildpacks|paketo-buildpacks|' - mapper_2: '|tanzu-buildpacks\/|pivotal-cf/tanzu-|' + mapper_1: '|tanzu-buildpacks|paketo-buildpacks|' + mapper_2: '|tanzu-buildpacks\/|pivotal-cf/tanzu-|' release_body: ${{ steps.release-drafter.outputs.body }} release_id: ${{ steps.release-drafter.outputs.id }} release_name: ${{ steps.release-drafter.outputs.name }} diff --git a/actions/compute-artifact-description/main.go b/actions/compute-artifact-description/main.go index 222971da..65fb2760 100644 --- a/actions/compute-artifact-description/main.go +++ b/actions/compute-artifact-description/main.go @@ -33,6 +33,17 @@ import ( func main() { inputs := actions.NewInputs() + if _, found := inputs["package"]; !found { + panic(fmt.Errorf("unable to read package, package must be set")) + } + + if _, found := inputs["version"]; !found { + panic(fmt.Errorf("unable to read version, version must be set")) + } + + imgUri := fmt.Sprintf("%s:%s", inputs["package"], inputs["version"]) + fmt.Println("Loading image URI:", imgUri) + var c *http.Client if s, ok := inputs["github_token"]; ok { c = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: s})) @@ -44,7 +55,7 @@ func main() { RegexMappers: parseMappers(inputs), } - mainBp, err := loader.LoadBuildpack(inputs["package"]) + mainBp, err := loader.LoadBuildpack(imgUri) if err != nil { panic(err) }