Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
106 changes: 106 additions & 0 deletions .github/workflows/compile-dependency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: 'Compile Dependency on Target - Reusable Workflow'

description: |
Compiles Dependency on given target, os, and arch

on:
workflow_call:
inputs:
version:
description: 'dependency version'
required: true
type: string
target:
description: 'dependency OS target variant'
required: true
type: string
os:
description: 'platform OS (e.g., linux)'
required: true
type: string
arch:
description: 'platform architecture (e.g., amd64)'
required: true
type: string
shouldCompile:
description: 'whether to compile the dependency'
required: true
type: boolean
shouldTest:
description: 'whether to test the dependency after compilation'
required: true
type: boolean
uploadArtifactName:
description: 'name of the artifact to upload'
required: true
type: string

jobs:
compile:
# Speed up compilation by using runners that match os and arch when they are set, otherwise fall back to emulation.
runs-on: ${{ (inputs.os == 'linux' && inputs.arch == 'arm64') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Enable experimental features for Docker daemon and CLI
run: |
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
mkdir -p ~/.docker
echo '{"experimental": "enabled"}' | sudo tee ~/.docker/config.json

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup before compilation
id: compile-setup
run: |
echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: docker build
id: docker-build
env:
SKIP_LOGIN: true
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
uses: actions-hub/docker/cli@master
with:
args: "build ${{ (inputs.os != '' && inputs.arch != '') && format('--platform {0}/{1}', inputs.os, inputs.arch) || '' }} -t compilation -f dependency/actions/compile/${{ inputs.target }}.Dockerfile dependency/actions/compile"

- name: docker run
id: docker-run
uses: actions-hub/docker/cli@master
env:
SKIP_LOGIN: true
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
with:
args: "run ${{ (inputs.os != '' && inputs.arch != '') && format('--platform {0}/{1}', inputs.os, inputs.arch) || '' }} -v ${{ steps.compile-setup.outputs.outputdir }}:/home compilation --outputDir /home --target ${{ inputs.target }} --version ${{ inputs.version }} ${{ inputs.os != '' && format('--os {0}', inputs.os) || '' }} ${{ inputs.arch != '' && format('--arch {0}', inputs.arch) || '' }}"

- name: Print contents of output dir
shell: bash
run: ls -lah ${{ steps.compile-setup.outputs.outputdir }}

- name: Test Dependency
working-directory: dependency
if: ${{ (inputs.shouldCompile == true || inputs.shouldCompile == 'true') && (inputs.shouldTest == true || inputs.shouldTest == 'true') }}
run: |
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit

make test \
version="${{ inputs.version }}" \
tarballPath="${{ steps.compile-setup.outputs.outputdir }}/*.tgz" \
os="${{ inputs.os }}" \
arch="${{ inputs.arch }}"

- name: Upload compiled artifact
uses: actions/upload-artifact@v4
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
with:
name: '${{ inputs.uploadArtifactName }}'
path: '${{ steps.compile-setup.outputs.outputdir }}/*'
95 changes: 81 additions & 14 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ jobs:
name: Release
runs-on: ubuntu-24.04
needs: integration
services:
registry:
image: registry:2
ports:
- 5000:5000

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -110,13 +116,86 @@ jobs:
echo "buildpack_type=buildpack" >> "$GITHUB_OUTPUT"
fi

- name: Get buildpack path
id: get_buildpack_path
run: |

if [ -f "build/buildpackage.cnb" ]; then
echo "path=build/buildpackage.cnb" >> "$GITHUB_OUTPUT"
else
echo "path=build/buildpackage-linux-amd64.cnb" >> "$GITHUB_OUTPUT"
fi

- name: Create Release Notes
id: create-release-notes
uses: paketo-buildpacks/github-config/actions/release/notes@main
with:
repo: ${{ github.repository }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
buildpack_type: ${{ steps.get_buildpack_type.outputs.buildpack_type }}
buildpackage_path: ${{ steps.get_buildpack_path.outputs.path }}

- name: Get Image Digest
id: image_digest
run: |
image_name="localhost:5000/npm-install:latest"

./scripts/publish.sh \
--buildpack-type ${{ steps.get_buildpack_type.outputs.buildpack_type }} \
--image-ref $image_name

echo "digest=$(sudo skopeo inspect "docker://${image_name}" --tls-verify=false | jq -r .Digest)" >> "$GITHUB_OUTPUT"

- name: Set Correct Image Digest on the Release notes
run: |
printf '${{ steps.create-release-notes.outputs.release_body }}' \
| sed -E \
"s/\*\*Digest:\*\* \`sha256:[a-f0-9]{64}\`/\*\*Digest:\*\* \`${{ steps.image_digest.outputs.digest }}\`/" \
> ./release_notes

printf '${{ steps.image_digest.outputs.digest }}' > ./index-digest.sha256

- name: Create release assets
id: create_release_assets
run: |
release_assets=$(jq -n --arg repo_name "${{ github.event.repository.name }}" --arg tag "${{ steps.tag.outputs.tag }}" '
[
{
"path": "build/buildpack.tgz",
"name": ($repo_name + "-" + $tag + ".tgz"),
"content_type": "application/gzip"
},
{
"path": "./index-digest.sha256",
"name": ($repo_name + "-" + $tag + "-" + "index-digest.sha256"),
"content_type": "text/plain"
}
]')

for filepath in build/*.cnb; do
filename=$(basename "$filepath")
asset_name=""
if [[ "$filename" == "buildpackage-linux-amd64.cnb" ]]; then
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb"
elif [[ "$filename" == "buildpackage.cnb" ]]; then
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb"
else
formatted_filename="${filename#buildpackage-}"
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}-${formatted_filename}"
fi

release_assets=$(echo "$release_assets" | jq --arg asset_name "${asset_name}" --arg filepath "$filepath" '
. + [
{
"path": $filepath,
"name": $asset_name,
"content_type": "application/gzip"
}
]')
done

release_assets=$(jq -c <<< "$release_assets" )
printf "release_assets=%s\n" "${release_assets}" >> "$GITHUB_OUTPUT"

- name: Create Release
uses: paketo-buildpacks/github-config/actions/release/create@main
Expand All @@ -126,21 +205,9 @@ jobs:
tag_name: v${{ steps.tag.outputs.tag }}
target_commitish: ${{ github.sha }}
name: v${{ steps.tag.outputs.tag }}
body: ${{ steps.create-release-notes.outputs.release_body }}
body_filepath: "./release_notes"
draft: true
assets: |
[
{
"path": "build/buildpack.tgz",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz",
"content_type": "application/gzip"
},
{
"path": "build/buildpackage.cnb",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb",
"content_type": "application/gzip"
}
]
assets: ${{ steps.create_release_assets.outputs.release_assets }}

failure:
name: Alert on Failure
Expand Down
109 changes: 85 additions & 24 deletions .github/workflows/push-buildpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ on:
release:
types:
- published

env:
REGISTRIES_FILENAME: "registries.json"

jobs:
push:
name: Push
runs-on: ubuntu-24.04
env:
GCR_REGISTRY: "gcr.io"
GCR_PASSWORD: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }}
GCR_USERNAME: "_json_key"
DOCKERHUB_REGISTRY: docker.io
DOCKERHUB_USERNAME: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }}

steps:

- name: Checkout
Expand All @@ -25,16 +34,31 @@ jobs:
echo "tag_full=${FULL_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag_minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag_major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT"
echo "download_url=$(jq -r '.release.assets[] | select(.name | endswith(".cnb")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"
echo "download_tgz_file_url=$(jq -r '.release.assets[] | select(.name | endswith(".tgz")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"
echo "download_cnb_file_url=$(jq -r --arg tag_full "$FULL_VERSION" '.release.assets[] | select(.name | endswith($tag_full + ".cnb")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"
echo "download_sha256_file_url=$(jq -r '.release.assets[] | select(.name | endswith("index-digest.sha256")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"

- name: Download
id: download
- name: Download .cnb buildpack
uses: paketo-buildpacks/github-config/actions/release/download-asset@main
with:
url: ${{ steps.event.outputs.download_url }}
url: ${{ steps.event.outputs.download_cnb_file_url }}
output: "/github/workspace/buildpackage.cnb"
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

- name: Download .tgz buildpack
uses: paketo-buildpacks/github-config/actions/release/download-asset@main
with:
url: ${{ steps.event.outputs.download_tgz_file_url }}
output: "/github/workspace/buildpack.tgz"
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

- name: Download .sha digest
uses: paketo-buildpacks/github-config/actions/release/download-asset@main
with:
url: ${{ steps.event.outputs.download_sha256_file_url }}
output: "/github/workspace/index-digest.sha256"
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

- name: Parse Configs
id: parse_configs
run: |
Expand Down Expand Up @@ -64,41 +88,78 @@ jobs:
exit 1
fi

- name: Push to GCR
if: ${{ steps.parse_configs.outputs.push_to_gcr == 'true' }}
env:
GCR_PUSH_BOT_JSON_KEY: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }}
- name: Get buildpack type
id: get_buildpack_type
run: |
echo "${GCR_PUSH_BOT_JSON_KEY}" | sudo skopeo login --username _json_key --password-stdin gcr.io
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_minor }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_major }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:latest"
if [ -f "extension.toml" ]; then
echo "buildpack_type=extension" >> "$GITHUB_OUTPUT"
else
echo "buildpack_type=buildpack" >> "$GITHUB_OUTPUT"
fi

- name: Docker login docker.io
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_PASSWORD }}
registry: ${{ env.DOCKERHUB_REGISTRY }}

- name: Docker login gcr.io
uses: docker/login-action@v3
if: ${{ steps.parse_configs.outputs.push_to_gcr == 'true' }}
with:
username: ${{ env.GCR_USERNAME }}
password: ${{ env.GCR_PASSWORD }}
registry: ${{ env.GCR_REGISTRY }}

- uses: buildpacks/github-actions/[email protected]
- name: Push to DockerHub
if: ${{ steps.parse_configs.outputs.push_to_dockerhub == 'true' }}
id: push
env:
DOCKERHUB_USERNAME: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
REPOSITORY="${GITHUB_REPOSITORY_OWNER/-/}/${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" # translates 'paketo-buildpacks/bundle-install' to 'paketobuildpacks/bundle-install'
IMAGE="index.docker.io/${REPOSITORY}"
echo "${DOCKERHUB_PASSWORD}" | sudo skopeo login --username "${DOCKERHUB_USERNAME}" --password-stdin index.docker.io
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_full }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_minor }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_major }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:latest"
IMAGE="${GITHUB_REPOSITORY_OWNER/-/}/${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" # translates 'paketo-buildpacks/bundle-install' to 'paketobuildpacks/bundle-install'
echo "${DOCKERHUB_PASSWORD}" | sudo skopeo login --username "${DOCKERHUB_USERNAME}" --password-stdin ${DOCKERHUB_REGISTRY}

./scripts/publish.sh \
--archive-path ./buildpack.tgz \
--buildpack-type ${{ steps.get_buildpack_type.outputs.buildpack_type }} \
--image-ref "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}"

## Validate that the image index digest pushed to registry matches with the one on the release notes
pushed_image_index_digest=$(crane digest "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" | xargs)

echo "Index digest from release notes: $(cat ./index-digest.sha256)"
echo "Index digest pushed to registry: $pushed_image_index_digest"

if [ "$(cat ./index-digest.sha256)" != "$pushed_image_index_digest" ]; then
echo "The image index digest pushed to registry does not match the expected digest from release notes"
exit 1;
fi

sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_minor }}" --multi-arch all
sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_major }}" --multi-arch all
sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "docker://${DOCKERHUB_REGISTRY}/${IMAGE}:latest" --multi-arch all
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
echo "digest=$(sudo skopeo inspect "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" | jq -r .Digest)" >> "$GITHUB_OUTPUT"
echo "digest=$pushed_image_index_digest" >> "$GITHUB_OUTPUT"

- name: Push to GCR
if: ${{ steps.parse_configs.outputs.push_to_gcr == 'true' }}
run: |
echo "${GCR_PASSWORD}" | sudo skopeo login --username "${GCR_USERNAME}" --password-stdin "${GCR_REGISTRY}"

sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${{ steps.push.outputs.image }}" "docker://${GCR_REGISTRY}/${{ github.repository }}:${{ steps.event.outputs.tag_full }}" --multi-arch all
sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${{ steps.push.outputs.image }}" "docker://${GCR_REGISTRY}/${{ github.repository }}:${{ steps.event.outputs.tag_minor }}" --multi-arch all
sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${{ steps.push.outputs.image }}" "docker://${GCR_REGISTRY}/${{ github.repository }}:${{ steps.event.outputs.tag_major }}" --multi-arch all
sudo skopeo copy "docker://${DOCKERHUB_REGISTRY}/${{ steps.push.outputs.image }}" "docker://${GCR_REGISTRY}/${{ github.repository }}:latest" --multi-arch all

- name: Register with CNB Registry
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:main
with:
id: ${{ github.repository }}
version: ${{ steps.event.outputs.tag_full }}
address: ${{ steps.push.outputs.image }}@${{ steps.push.outputs.digest }}
address: index.docker.io/${{ steps.push.outputs.image }}@${{ steps.push.outputs.digest }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

failure:
Expand Down
2 changes: 1 addition & 1 deletion scripts/.util/tools.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"createpackage": "v1.73.0",
"jam": "v2.13.0",
"jam": "v2.15.0",
"libpaktools": "v0.3.0",
"pack": "v0.38.2"
}
Loading
Loading