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

Add version to compute artifact action #653

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion actions/compute-artifact-description/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand All @@ -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)
}
Expand Down