From 424d74d717dca835dc9091c62e86e48b148430ae Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Thu, 28 Mar 2024 23:49:10 -0400 Subject: [PATCH] Changes to support ARM64 Signed-off-by: Daniel Mikusa --- .github/pipeline-descriptor.yml | 11 ++ .github/workflows/pb-update-tini-arm-64.yml | 106 ++++++++++++++++++++ .gitignore | 4 +- buildpack.toml | 28 +++++- scripts/build.sh | 15 +-- 5 files changed, 155 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/pb-update-tini-arm-64.yml diff --git a/.github/pipeline-descriptor.yml b/.github/pipeline-descriptor.yml index 331f7f2..317e154 100644 --- a/.github/pipeline-descriptor.yml +++ b/.github/pipeline-descriptor.yml @@ -28,3 +28,14 @@ dependencies: owner: krallin repository: tini token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + +# ARM64 +- name: Tini ARM64 + id: tini + uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main + with: + glob: tini-static-arm64 + owner: krallin + repository: tini + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + arch: arm64 diff --git a/.github/workflows/pb-update-tini-arm-64.yml b/.github/workflows/pb-update-tini-arm-64.yml new file mode 100644 index 0000000..f8e09ce --- /dev/null +++ b/.github/workflows/pb-update-tini-arm-64.yml @@ -0,0 +1,106 @@ +name: Update Tini ARM64 +"on": + schedule: + - cron: 0 5 * * 1-5 + workflow_dispatch: {} +jobs: + update: + name: Update Buildpack Dependency + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v5 + with: + go-version: "1.20" + - name: Install update-buildpack-dependency + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/update-buildpack-dependency@latest + - uses: buildpacks/github-actions/setup-tools@v5.5.3 + with: + crane-version: 0.19.0 + yj-version: 5.1.0 + - uses: actions/checkout@v4 + - id: dependency + uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main + with: + arch: arm64 + glob: tini-static-arm64 + owner: krallin + repository: tini + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + - name: Update Buildpack Dependency + id: buildpack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + VERSION_DEPS=$(yj -tj < buildpack.toml | jq -r ".metadata.dependencies[] | select( .id == env.ID ) | select( .version | test( env.VERSION_PATTERN ) )") + ARCH=${ARCH:-amd64} + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r 'select( .purl | contains( env.ARCH ) ) | .version') + + if [ -z "$OLD_VERSION" ]; then + ARCH="" # empty means noarch + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r ".version") + fi + + update-buildpack-dependency \ + --buildpack-toml buildpack.toml \ + --id "${ID}" \ + --arch "${ARCH}" \ + --version-pattern "${VERSION_PATTERN}" \ + --version "${VERSION}" \ + --cpe-pattern "${CPE_PATTERN:-}" \ + --cpe "${CPE:-}" \ + --purl-pattern "${PURL_PATTERN:-}" \ + --purl "${PURL:-}" \ + --uri "${URI}" \ + --sha256 "${SHA256}" \ + --source "${SOURCE_URI}" \ + --source-sha256 "${SOURCE_SHA256}" + + git add buildpack.toml + git checkout -- . + + if [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $1}')" != "$(echo "$VERSION" | awk -F '.' '{print $1}')" ]; then + LABEL="semver:major" + elif [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $2}')" != "$(echo "$VERSION" | awk -F '.' '{print $2}')" ]; then + LABEL="semver:minor" + else + LABEL="semver:patch" + fi + + echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT" + echo "new-version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "version-label=${LABEL}" >> "$GITHUB_OUTPUT" + env: + ARCH: arm64 + CPE: ${{ steps.dependency.outputs.cpe }} + CPE_PATTERN: "" + ID: tini + PURL: ${{ steps.dependency.outputs.purl }} + PURL_PATTERN: "" + SHA256: ${{ steps.dependency.outputs.sha256 }} + SOURCE_SHA256: ${{ steps.dependency.outputs.source_sha256 }} + SOURCE_URI: ${{ steps.dependency.outputs.source }} + URI: ${{ steps.dependency.outputs.uri }} + VERSION: ${{ steps.dependency.outputs.version }} + VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+' + - uses: peter-evans/create-pull-request@v6 + with: + author: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} <${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}@users.noreply.github.com> + body: Bumps `Tini ARM64` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. + branch: update/buildpack/tini-arm-64 + commit-message: |- + Bump Tini ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + + Bumps Tini ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}. + delete-branch: true + labels: ${{ steps.buildpack.outputs.version-label }}, type:dependency-upgrade + signoff: true + title: Bump Tini ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index d9a220c..2f65ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Copyright 2018-2021 the original author or authors. +# Copyright 2018-2020 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,6 +13,8 @@ # limitations under the License. bin/ +linux/ dependencies/ package/ scratch/ + diff --git a/buildpack.toml b/buildpack.toml index 6575ba9..c6b5d37 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -28,7 +28,7 @@ api = "0.7" uri = "https://github.com/paketo-community/cargo/blob/main/LICENSE" [metadata] - include-files = ["LICENSE", "NOTICE", "README.md", "bin/build", "bin/detect", "bin/main", "buildpack.toml"] + include-files = ["LICENSE", "NOTICE", "README.md", "buildpack.toml", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main"] pre-package = "scripts/build.sh" [[metadata.configurations]] @@ -89,7 +89,7 @@ api = "0.7" cpes = ["cpe:2.3:a:tini_project:tini:0.19.0:*:*:*:*:*:*:*"] id = "tini" name = "Tini" - purl = "pkg:generic/tini@v0.19.0" + purl = "pkg:generic/tini@v0.19.0?arch=amd64" sha256 = "77cce5f4e61954b3420c4465197d8b826a4cf978eba016a9c5859eea0e4c0866" source = "https://github.com/krallin/tini/archive/refs/tags/v0.19.0.tar.gz" source-sha256 = "0fd35a7030052acd9f58948d1d900fe1e432ee37103c5561554408bdac6bbf0d" @@ -101,5 +101,29 @@ api = "0.7" type = "MIT" uri = "https://github.com/krallin/tini/blob/master/LICENSE" + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:tini_project:tini:0.19.0:*:*:*:*:*:*:*"] + id = "tini" + name = "Tini" + purl = "pkg:generic/tini@v0.19.0?arch=arm64" + sha256 = "eae1d3aa50c48fb23b8cbdf4e369d0910dfc538566bfd09df89a774aa84a48b9" + source = "https://github.com/krallin/tini/archive/refs/tags/v0.19.0.tar.gz" + source-sha256 = "0fd35a7030052acd9f58948d1d900fe1e432ee37103c5561554408bdac6bbf0d" + stacks = ["*"] + uri = "https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-arm64" + version = "0.19.0" + + [[metadata.dependencies.licenses]] + type = "MIT" + uri = "https://github.com/krallin/tini/blob/master/LICENSE" + [[stacks]] id = "*" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux" diff --git a/scripts/build.sh b/scripts/build.sh index 64b95e8..dc48240 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,16 +1,19 @@ #!/usr/bin/env bash - set -euo pipefail -GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/paketo-community/cargo/cmd/main +GOMOD=$(head -1 go.mod | awk '{print $2}') +GOOS="linux" go build -ldflags='-s -w' -o linux/amd64/bin/main "$GOMOD/cmd/main" +GOOS="linux" GOARCH="arm64" go build -ldflags='-s -w' -o linux/arm64/bin/main "$GOMOD/cmd/main" if [ "${STRIP:-false}" != "false" ]; then - strip bin/main + strip linux/amd64/bin/main linux/arm64/bin/main fi if [ "${COMPRESS:-none}" != "none" ]; then - $COMPRESS bin/main + $COMPRESS linux/amd64/bin/main linux/arm64/bin/main fi -ln -fs main bin/build -ln -fs main bin/detect +ln -fs main linux/amd64/bin/build +ln -fs main linux/arm64/bin/build +ln -fs main linux/amd64/bin/detect +ln -fs main linux/arm64/bin/detect \ No newline at end of file