Skip to content

Commit

Permalink
Merge pull request #299 from paketo-community/arm64
Browse files Browse the repository at this point in the history
Changes to support ARM64
  • Loading branch information
dmikusa authored Mar 29, 2024
2 parents e391325 + c58eb1e commit 5f828fe
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 20 deletions.
12 changes: 11 additions & 1 deletion .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ docker_credentials:
password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }}

dependencies:
- id: rust
- name: Rust
id: rust
uses: docker://ghcr.io/paketo-buildpacks/actions/rust-dependency:main
with:
target: x86_64-unknown-linux-gnu
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

# ARM64
- name: Rust ARM64
id: rust
uses: docker://ghcr.io/paketo-buildpacks/actions/rust-dependency:main
with:
target: aarch64-unknown-linux-gnu
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
arch: arm64
104 changes: 104 additions & 0 deletions .github/workflows/pb-update-rust-arm-64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Update Rust 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/rust-dependency:main
with:
arch: arm64
target: aarch64-unknown-linux-gnu
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: rust
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 `Rust ARM64` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/rust-arm-64
commit-message: |-
Bump Rust ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bumps Rust 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 Rust ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/pb-update-rust.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update rust
name: Update Rust
"on":
schedule:
- cron: 0 5 * * 1-5
Expand Down Expand Up @@ -90,14 +90,14 @@ jobs:
- 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 `rust` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
body: Bumps `Rust` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/rust
commit-message: |-
Bump rust from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bump Rust from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
Bumps rust from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
Bumps Rust 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 rust from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
title: Bump Rust from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,6 +13,8 @@
# limitations under the License.

bin/
linux/
dependencies/
package/
scratch/

36 changes: 29 additions & 7 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ api = "0.7"
uri = "https://github.com/paketo-community/rust-dist/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]]
Expand All @@ -41,11 +41,11 @@ api = "0.7"
cpes = ["cpe:2.3:a:rust:rust:1.77.0:*:*:*:*:*:*:*"]
id = "rust"
name = "Rust"
purl = "pkg:generic/rust@1.77.0"
purl = "pkg:generic/rust@1.77.0?arch=amd64"
sha256 = "cbdd1b93046ea4aed974016e328cb09ad0b8ee96893bd5d548fd3e7907607c75"
source = "https://static.rust-lang.org/dist/rustc-1.77.0-src.tar.gz"
source-sha256 = "0d6ccd1fa845fe3456b9ed4d483fc06acf9bbae9417e396b5144488c1a522d87"
stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"]
stacks = ["*"]
uri = "https://static.rust-lang.org/dist/rust-1.77.0-x86_64-unknown-linux-gnu.tar.gz"
version = "1.77.0"

Expand All @@ -57,11 +57,33 @@ api = "0.7"
type = "MIT"
uri = "https://github.com/rust-lang/rust/blob/master/LICENSE-MIT"

[[stacks]]
id = "io.buildpacks.stacks.bionic"
[[metadata.dependencies]]
cpes = ["cpe:2.3:a:rust:rust:1.77.0:*:*:*:*:*:*:*"]
id = "rust"
name = "Rust"
purl = "pkg:generic/rust@1.77.0?arch=arm64"
sha256 = "df4630b250c53227649214fa5d57240217686e86bf502e5de0402d3264cb74d8"
source = "https://static.rust-lang.org/dist/rustc-1.77.0-src.tar.gz"
source-sha256 = "0d6ccd1fa845fe3456b9ed4d483fc06acf9bbae9417e396b5144488c1a522d87"
stacks = ["*"]
uri = "https://static.rust-lang.org/dist/rust-1.77.0-aarch64-unknown-linux-gnu.tar.gz"
version = "1.77.0"

[[stacks]]
id = "io.paketo.stacks.tiny"
[[metadata.dependencies.licenses]]
type = "Apache-2.0"
uri = "https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE"

[[metadata.dependencies.licenses]]
type = "MIT"
uri = "https://github.com/rust-lang/rust/blob/master/LICENSE-MIT"

[[stacks]]
id = "*"

[[targets]]
arch = "amd64"
os = "linux"

[[targets]]
arch = "arm64"
os = "linux"
15 changes: 9 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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/rust-dist/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

0 comments on commit 5f828fe

Please sign in to comment.