From 2a85ce045a579414af956324adc37273d4f8af39 Mon Sep 17 00:00:00 2001 From: Sam Ansmink Date: Wed, 31 Jan 2024 13:59:09 +0100 Subject: [PATCH] add missing script --- scripts/extension-upload.sh | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/extension-upload.sh diff --git a/scripts/extension-upload.sh b/scripts/extension-upload.sh new file mode 100755 index 0000000..3eb3b67 --- /dev/null +++ b/scripts/extension-upload.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Extension upload script + +# Usage: ./extension-upload-oote.sh +# : Name of the extension +# : Version (commit / version tag) of the extension +# : Version (commit / version tag) of DuckDB +# : Architecture target of the extension binary +# : S3 bucket to upload to +# : Set this as the latest version ("true" / "false", default: "false") +# : Set this as a versioned version that will prevent its deletion + +set -e + +ext="/tmp/extension/$1.duckdb_extension" + +script_dir="$(dirname "$(readlink -f "$0")")" + +# Abort if AWS key is not set +if [ -z "$AWS_ACCESS_KEY_ID" ]; then + echo "No AWS key found, skipping.." + exit 0 +fi + +# (Optionally) Sign binary +if [ "$DUCKDB_EXTENSION_SIGNING_PK" != "" ]; then + echo "$DUCKDB_EXTENSION_SIGNING_PK" > private.pem + $script_dir/../duckdb/scripts/compute-extension-hash.sh $ext > $ext.hash + openssl pkeyutl -sign -in $ext.hash -inkey private.pem -pkeyopt digest:sha256 -out $ext.sign + cat $ext.sign >> $ext +fi + +set -e + +# compress extension binary +gzip < "${ext}" > "$ext.gz" + +# upload versioned version +if [[ $7 = 'true' ]]; then + aws s3 cp $ext.gz s3://$5/$1/$2/$3/$4/$1.duckdb_extension.gz --acl public-read +fi + +# upload to latest version +if [[ $6 = 'true' ]]; then + aws s3 cp $ext.gz s3://$5/$3/$4/$1.duckdb_extension.gz --acl public-read +fi + +if [ "$DUCKDB_EXTENSION_SIGNING_PK" != "" ]; then + rm private.pem +fi \ No newline at end of file