debug symbol upload (#7783)

Conrad Irwin created

This will let it become slowly eaasier to debug crashes

Release Notes:

- N/A

Change summary

.github/workflows/ci.yml |  2 ++
script/bundle            | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)

Detailed changes

.github/workflows/ci.yml 🔗

@@ -137,6 +137,8 @@ jobs:
             APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
             APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
             ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
+            DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
+            DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
         steps:
             - name: Install Node
               uses: actions/setup-node@v4

script/bundle 🔗

@@ -30,6 +30,30 @@ Options:
   "
 }
 
+function uploadDsym
+{
+  SPACE="zed-debug-symbols"
+  REGION="nyc3"
+  file_to_upload="$1"
+  file_name="$2"
+  space_path="nightly"
+  date=$(date +"%a, %d %b %Y %T %z")
+  acl="x-amz-acl:public-read"
+  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)
+
+  curl --fail -vv -s -X PUT -T "$file_to_upload" \
+    -H "Host: ${SPACE}.${REGION}.digitaloceanspaces.com" \
+    -H "Date: $date" \
+    -H "Content-Type: $content_type" \
+    -H "$storage_type" \
+    -H "$acl" \
+    -H "Authorization: AWS ${DIGITALOCEAN_SPACES_ACCESS_KEY}:$signature" \
+    "https://${SPACE}.${REGION}.digitaloceanspaces.com/${space_path}/${file_name}"
+}
+
 while getopts 'dlfoh' flag
 do
     case "${flag}" in
@@ -111,6 +135,16 @@ popd
 echo "Bundled ${app_path}"
 
 if [ "$local_arch" = false ]; then
+    echo "Uploading dSYMs"
+    dsymutil --flat target/aarch64-apple-darwin/release/Zed
+    dsymutil --flat target/x86_64-apple-darwin/release/Zed
+    version="$(cargo metadata --no-deps --manifest-path crates/zed/Cargo.toml --offline --format-version=1 | jq -r '.packages | map(select(.name == "zed"))[0].version')"
+    if [ "$channel" == "nightly" ]; then
+        version="$version-$(git rev-parse --short HEAD)"
+    fi
+    uploadDsym target/aarch64-apple-darwin/release/Zed.dwarf "$channel/Zed-$version-aarch64-apple-darwin.dwarf"
+    uploadDsym target/x86_64-apple-darwin/release/Zed.dwarf "$channel/Zed-$version-x86_64-apple-darwin.dwarf"
+
     echo "Creating fat binaries"
     lipo \
         -create \