Skip to content

Commit 2f3ff33

Browse files
authored
Merge pull request #1 from heroku/malax/update-from-jvm
Add GHA workflows from buildpacks-jvm
2 parents e795815 + 3a31bb2 commit 2f3ff33

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "bundler"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- "skip changelog"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script is an integral part of the release workflow: .github/workflows/release.yml
5+
# It requires the following environment variables to function correctly:
6+
#
7+
# REQUESTED_BUILDPACK_ID - The ID of the buildpack to package and push to the container registry.
8+
9+
while IFS="" read -r -d "" buildpack_toml_path; do
10+
buildpack_id="$(yj -t <"${buildpack_toml_path}" | jq -r .buildpack.id)"
11+
buildpack_version="$(yj -t <"${buildpack_toml_path}" | jq -r .buildpack.version)"
12+
buildpack_docker_repository="$(yj -t <"${buildpack_toml_path}" | jq -r .metadata.release.docker.repository)"
13+
buildpack_path=$(dirname "${buildpack_toml_path}")
14+
15+
if [[ $buildpack_id == "${REQUESTED_BUILDPACK_ID}" ]]; then
16+
cnb_shim_tarball_url="https://github.com/heroku/cnb-shim/releases/download/v0.3/cnb-shim-v0.3.tgz"
17+
cnb_shim_tarball_sha256="109cfc01953cb04e69c82eec1c45c7c800bd57d2fd0eef030c37d8fc37a1cb4d"
18+
local_cnb_shim_tarball=$(mktemp)
19+
20+
v2_buildpack_tarball_url="$(yj -t <"${buildpack_toml_path}" | jq -r ".metadata.shim.tarball // empty")"
21+
v2_buildpack_tarball_sha256="$(yj -t <"${buildpack_toml_path}" | jq -r ".metadata.shim.sha256 // empty")"
22+
local_v2_buildpack_tarball=$(mktemp)
23+
24+
# If the buildpack has a V2 buildpack tarball in its metadata it's supposed to be a shimmed buildpack.
25+
# We download the shim and the V2 buildpack to the buildpack directory, turning it into a CNB. This
26+
# transformation is transparent for the code that follows after it.
27+
if [[ -n "${v2_buildpack_tarball_url:-}" ]]; then
28+
curl --retry 3 --location "${cnb_shim_tarball_url}" --output "${local_cnb_shim_tarball}"
29+
curl --retry 3 --location "${v2_buildpack_tarball_url}" --output "${local_v2_buildpack_tarball}"
30+
31+
if ! echo "${cnb_shim_tarball_sha256} ${local_cnb_shim_tarball}" | sha256sum --check --status; then
32+
echo "Checksum verification of cnb_shim failed!"
33+
exit 1
34+
fi
35+
36+
if ! echo "${v2_buildpack_tarball_sha256} ${local_v2_buildpack_tarball}" | sha256sum --check --status; then
37+
echo "Checksum verification of V2 buildpack tarball failed!"
38+
exit 1
39+
fi
40+
41+
mkdir -p "${buildpack_path}/target"
42+
tar -xzmf "${local_cnb_shim_tarball}" -C "${buildpack_path}"
43+
tar -xzmf "${local_v2_buildpack_tarball}" -C "${buildpack_path}/target"
44+
fi
45+
46+
image_name="${buildpack_docker_repository}:${buildpack_version}"
47+
pack package-buildpack --config "${buildpack_path}/package.toml" --publish "${image_name}"
48+
49+
echo "::set-output name=id::${buildpack_id}"
50+
echo "::set-output name=version::${buildpack_version}"
51+
echo "::set-output name=path::${buildpack_path}"
52+
echo "::set-output name=address::${buildpack_docker_repository}@$(crane digest "${image_name}")"
53+
exit 0
54+
fi
55+
done < <(find . -name buildpack.toml -print0)
56+
57+
echo "Could not find requested buildpack with id ${REQUESTED_BUILDPACK_ID}!"
58+
exit 1

.github/workflows/release.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release Buildpack
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
requested_buildpack_id:
6+
description: "Buildpack ID"
7+
required: true
8+
9+
jobs:
10+
release:
11+
name: Release ${{ github.event.inputs.requested_buildpack_id }}
12+
runs-on: ubuntu-20.04 # ubuntu-latest currently resolves to 18.04 which does not have aws-cli 2.x yet
13+
env:
14+
REQUESTED_BUILDPACK_ID: ${{ github.event.inputs.requested_buildpack_id }}
15+
steps:
16+
- id: checkout
17+
name: "Checkout code"
18+
uses: actions/checkout@v2
19+
- id: setup-pack
20+
name: "Setup pack"
21+
uses: buildpacks/github-actions/[email protected]
22+
- id: login
23+
name: "Login to public ECR"
24+
uses: docker/login-action@v1
25+
with:
26+
registry: public.ecr.aws
27+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
env:
30+
AWS_REGION: us-east-1
31+
- id: package
32+
name: "Package buildpack and publish to container registry"
33+
run: ./.github/scripts/release-workflow-package-push.sh
34+
shell: bash
35+
- id: add-registry-entry
36+
name: "Request Registry Entry"
37+
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:4.0.0
38+
with:
39+
token: ${{ secrets.PUBLIC_REPO_TOKEN }}
40+
id: ${{ steps.package.outputs.id }}
41+
version: ${{ steps.package.outputs.version }}
42+
address: ${{ steps.package.outputs.address }}
43+
- id: create_release
44+
name: Create Release
45+
uses: actions/create-release@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
tag_name: ${{ steps.package.outputs.id }}_${{ steps.package.outputs.version }}
50+
release_name: ${{ steps.package.outputs.id }} ${{ steps.package.outputs.version }}
51+
body: |
52+
Find the changelog here: [CHANGELOG](${{ steps.package.outputs.path }}/CHANGELOG.md)
53+
draft: false
54+
prerelease: false

0 commit comments

Comments
 (0)