2023-11-17 20:16:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Based on the template in: https://docs.digitalocean.com/reference/api/spaces-api/
|
2023-11-17 22:07:51 +00:00
|
|
|
set -ux
|
2023-11-17 20:16:55 +00:00
|
|
|
|
|
|
|
# Step 1: Define the parameters for the Space you want to upload to.
|
|
|
|
SPACE="zed-nightly-host" # Find your endpoint in the control panel, under Settings.
|
|
|
|
REGION="nyc3" # Must be "us-east-1" when creating new Spaces. Otherwise, use the region in your endpoint (e.g. nyc3).
|
|
|
|
|
|
|
|
# Step 2: Define a function that uploads your object via cURL.
|
2023-11-17 22:07:51 +00:00
|
|
|
function uploadToSpaces
|
2023-11-17 20:16:55 +00:00
|
|
|
{
|
2023-11-17 22:07:51 +00:00
|
|
|
file_to_upload="$1"
|
|
|
|
file_name="$2"
|
|
|
|
space_path="nightly"
|
2023-11-17 20:16:55 +00:00
|
|
|
date=$(date +"%a, %d %b %Y %T %z")
|
2023-11-17 22:07:51 +00:00
|
|
|
acl="x-amz-acl:private"
|
|
|
|
content_type="application/octet-stream"
|
|
|
|
storage_type="x-amz-storage-class:STANDARD"
|
|
|
|
string="PUT\n\n${content_type}\n${date}\n${acl}\n${storage_type}\n/${SPACE}/${space_path}/${file_name}"
|
|
|
|
signature=$(echo -en "${string}" | openssl sha1 -hmac "${DIGITALOCEAN_SPACES_SECRET_KEY}" -binary | base64)
|
|
|
|
|
2023-12-08 19:38:28 +00:00
|
|
|
curl --fail -vv -s -X PUT -T "$file_to_upload" \
|
2023-11-17 22:07:51 +00:00
|
|
|
-H "Host: ${SPACE}.${REGION}.digitaloceanspaces.com" \
|
2023-11-17 20:16:55 +00:00
|
|
|
-H "Date: $date" \
|
|
|
|
-H "Content-Type: $content_type" \
|
|
|
|
-H "$storage_type" \
|
|
|
|
-H "$acl" \
|
2023-11-17 22:07:51 +00:00
|
|
|
-H "Authorization: AWS ${DIGITALOCEAN_SPACES_ACCESS_KEY}:$signature" \
|
|
|
|
"https://${SPACE}.${REGION}.digitaloceanspaces.com/${space_path}/${file_name}"
|
2023-11-17 20:16:55 +00:00
|
|
|
}
|
|
|
|
|
2023-11-17 22:07:51 +00:00
|
|
|
sha=$(git rev-parse HEAD)
|
|
|
|
echo ${sha} > target/latest-sha
|
2023-11-17 20:16:55 +00:00
|
|
|
|
2023-11-17 22:07:51 +00:00
|
|
|
uploadToSpaces "target/release/Zed.dmg" "Zed.dmg"
|
|
|
|
uploadToSpaces "target/latest-sha" "latest-sha"
|