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 architecture support to get script #1682

Merged
merged 1 commit into from
Sep 12, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
mv target/x86_64-unknown-linux-gnu/release/conmonrs ${{ github.sha }}
- run: ./${{ github.sha }}/conmonrs -v
- uses: sigstore/cosign-installer@v3
if: github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags')
- name: Sign binary
if: github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags')
run: |
Expand Down Expand Up @@ -154,6 +155,7 @@ jobs:
mkdir ${{ github.sha }}
cp result/bin/conmonrs ${{ github.sha }}/conmonrs.${{ matrix.arch }}
- uses: sigstore/cosign-installer@v3
if: github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags')
- name: Sign binary
if: github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags')
run: |
Expand Down
42 changes: 35 additions & 7 deletions scripts/get
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@
set -euo pipefail

BASE_URL=https://storage.googleapis.com/cri-o/conmon-rs
ARCH_AMD64=amd64
ARCH_ARM64=arm64
ARCH_PPC64LE=ppc64le
ARCH=
COMMIT=
TAG=
OUTPUT=conmonrs

usage() {
printf "Usage: %s [ -t SHA ] [ -h ]\n\n" "$(basename "$0")"
printf "Usage: %s [ -t SHA ] [-l TAG ] [-a ARCH] [ -h ]\n\n" "$(basename "$0")"
echo "Possible arguments:"
printf " -o\tOutput path for the downloaded binary (defaults to './conmonrs')\n"
printf " -t\tFull length SHA to be used (defaults to the latest available main)\n"
printf " -l\tTag to be used\n"
printf " -a\tArchitecture to retrieve (defaults to the local system)\n"
printf " -h\tShow this help message\n"
}

parse_args() {
echo "Welcome to the conmon-rs install script!"

while getopts 'l:o:t:h' OPTION; do
while getopts 'a:l:o:t:h' OPTION; do
case "$OPTION" in
a)
ARCH="$OPTARG"
echo "Using architecture: $TAG"
;;
l)
TAG="$OPTARG"
echo "Using tag: $TAG"
Expand All @@ -42,6 +51,21 @@ parse_args() {
;;
esac
done

if [[ $ARCH == "" ]]; then
LOCAL_ARCH=$(uname -m)
if [[ "$LOCAL_ARCH" == x86_64 ]]; then
ARCH=$ARCH_AMD64
elif [[ "$LOCAL_ARCH" == aarch64 ]]; then
ARCH=$ARCH_ARM64
elif [[ "$LOCAL_ARCH" == "$ARCH_PPC64LE" ]]; then
ARCH=$ARCH_PPC64LE
else
echo "Unsupported local architecture: $LOCAL_ARCH"
exit 1
fi
echo "No architecture provided, using: $ARCH"
fi
}

verify_requirements() {
Expand Down Expand Up @@ -93,23 +117,27 @@ download_binary() {
trap 'rm -rf $TMPDIR' EXIT
pushd "$TMPDIR" >/dev/null

FILES=(conmonrs conmonrs.sig conmonrs.cert)
FILES=(
"conmonrs.$ARCH"
"conmonrs.$ARCH.sig"
"conmonrs.$ARCH.cert"
)
for FILE in "${FILES[@]}"; do
curl_retry "$BASE_URL/$COMMIT/$FILE" -o "$FILE"
done

SLUG=containers/conmon-rs
cosign verify-blob conmonrs \
cosign verify-blob "${FILES[0]}" \
--certificate-identity "https://github.com/$SLUG/.github/workflows/ci.yml@$GIT_REF" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
--certificate-github-workflow-name ci \
--certificate-github-workflow-repository "$SLUG" \
--certificate-github-workflow-ref "$GIT_REF" \
--signature conmonrs.sig \
--certificate conmonrs.cert
--signature "${FILES[1]}" \
--certificate "${FILES[2]}"

popd >/dev/null
mv "$TMPDIR/conmonrs" "$OUTPUT"
mv "$TMPDIR/${FILES[0]}" "$OUTPUT"
else
curl_retry "$BASE_URL/$COMMIT/conmonrs" -o "$OUTPUT"
fi
Expand Down
Loading