Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add GitHub Action for publishing the extension CLI (#9542)
Marshall Bowers905a24079a4d
diff --git a/.github/workflows/publish_extension_cli.yml b/.github/workflows/publish_extension_cli.ymlnew file mode 100644index 00000000000..eb6b468dd61--- /dev/null+++ b/.github/workflows/publish_extension_cli.yml@@ -0,0 +1,41 @@+name: Publish zed-extension CLI++on:+ push:+ tags:+ - extension-cli++env:+ CARGO_TERM_COLOR: always+ CARGO_INCREMENTAL: 0++jobs:+ publish:+ name: Publish zed-extension CLI+ runs-on:+ - ubuntu-latest+ steps:+ - name: Checkout repo+ uses: actions/checkout@v4+ with:+ clean: false+ submodules: "recursive"++ - name: Cache dependencies+ uses: swatinem/rust-cache@v2+ with:+ save-if: ${{ github.ref == 'refs/heads/main' }}++ - name: Configure linux+ shell: bash -euxo pipefail {0}+ run: script/linux++ - name: Build extension CLI+ run: cargo build --release --package extension_cli++ - name: Upload binary+ if: ${{ github.ref == 'refs/heads/main' }}+ env:+ DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}+ DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}+ run: script/upload-extension-cli ${{ github.sha }}diff --git a/script/bundle-mac b/script/bundle-macindex d9a8549e82b..80cdb57170c 100755--- a/script/bundle-mac+++ b/script/bundle-mac@@ -1,6 +1,7 @@#!/usr/bin/env bashset -euxo pipefail+source script/lib/blob-store.shbuild_flag="--release"target_dir="release"@@ -30,29 +31,6 @@ Options:"}-function uploadDsym-{- SPACE="zed-debug-symbols"- REGION="nyc3"- file_to_upload="$1"- file_name="$2"- 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}/${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/${file_name}"-}-while getopts 'dlfoh' flagdocase "${flag}" in@@ -152,7 +130,10 @@ function prepare_binaries() {gzip target/${architecture}/${target_dir}/Zed.dwarfecho "Uploading dSYMs for $architecture"- uploadDsym target/${architecture}/${target_dir}/Zed.dwarf.gz "$channel/Zed-$version-${architecture}.dwarf.gz"+ upload_to_blob_store_public \+ "zed-debug-symbols" \+ target/${architecture}/${target_dir}/Zed.dwarf.gz \+ "$channel/Zed-$version-${architecture}.dwarf.gz"cp target/${architecture}/${target_dir}/${binary_name} "${app_path}/Contents/MacOS/${zed_crate}"cp target/${architecture}/${target_dir}/cli "${app_path}/Contents/MacOS/cli"diff --git a/script/lib/blob-store.sh b/script/lib/blob-store.shnew file mode 100644index 00000000000..ecfb6dbf952--- /dev/null+++ b/script/lib/blob-store.sh@@ -0,0 +1,33 @@+function upload_to_blob_store_with_acl+{+ bucket_name="$1"+ file_to_upload="$2"+ blob_store_key="$3"+ acl="$4"++ 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/${bucket_name}/${blob_store_key}"+ 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: ${bucket_name}.nyc3.digitaloceanspaces.com" \+ -H "Date: $date" \+ -H "Content-Type: $content_type" \+ -H "$storage_type" \+ -H "$acl" \+ -H "Authorization: AWS ${DIGITALOCEAN_SPACES_ACCESS_KEY}:$signature" \+ "https://${bucket_name}.nyc3.digitaloceanspaces.com/${blob_store_key}"+}++function upload_to_blob_store_public+{+ upload_to_blob_store_with_acl $1 $2 $3 "x-amz-acl:public-read"+}++function upload_to_blob_store+{+ upload_to_blob_store_with_acl $1 $2 $3 "x-amz-acl:private"+}diff --git a/script/upload-extension-cli b/script/upload-extension-clinew file mode 100755index 00000000000..3af9c3251f7--- /dev/null+++ b/script/upload-extension-cli@@ -0,0 +1,15 @@+#!/usr/bin/env bash++bash -euo pipefail+source script/lib/blob-store.sh++commit=$1+if [ "$#" -ne 1 ] || ! [[ $commit =~ ^[0-9a-f]{40}$ ]]; then+ echo "Usage: $0 <git-sha>"+ exit 1+fi++bucket_name="zed-extension-cli"+target_triple=$(rustc -vV | sed -n 's|host: ||p')++upload_to_blob_store_public $bucket_name "target/release/zed-extension" "${commit}/${target_triple}/zed-extension"diff --git a/script/upload-nightly b/script/upload-nightlyindex 6e34f2159f8..68e321f9b62 100755--- a/script/upload-nightly+++ b/script/upload-nightly@@ -2,6 +2,7 @@# Based on the template in: https://docs.digitalocean.com/reference/api/spaces-api/bash -euo pipefail+source script/lib/blob-store.shallowed_targets=("linux-deb" "macos")is_allowed_target() {@@ -28,47 +29,22 @@ exit 1fiecho "Uploading nightly for target: $target"-# 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.-function uploadToSpaces-{- file_to_upload="$1"- file_name="$2"- space_path="nightly"- date=$(date +"%a, %d %b %Y %T %z")- 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)-- 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}"-}+bucket_name="zed-nightly-host"sha=$(git rev-parse HEAD)echo ${sha} > target/latest-shacase "$target" inmacos)- uploadToSpaces "target/aarch64-apple-darwin/release/Zed.dmg" "Zed-aarch64.dmg"- uploadToSpaces "target/x86_64-apple-darwin/release/Zed.dmg" "Zed-x86_64.dmg"- uploadToSpaces "target/release/Zed.dmg" "Zed.dmg"- uploadToSpaces "target/latest-sha" "latest-sha"+ upload_to_blob_store $bucket_name "target/aarch64-apple-darwin/release/Zed.dmg" "nightly/Zed-aarch64.dmg"+ upload_to_blob_store $bucket_name "target/x86_64-apple-darwin/release/Zed.dmg" "nightly/Zed-x86_64.dmg"+ upload_to_blob_store $bucket_name "target/release/Zed.dmg" "nightly/Zed.dmg"+ upload_to_blob_store $bucket_name "target/latest-sha" "nightly/latest-sha";;linux-deb)find target/release -type f -name "*.deb" -print0 | while IFS= read -r -d '' bundle_file; do- uploadToSpaces "$bundle_file" "$(basename "$bundle_file")"+ upload_to_blob_store $bucket_name "$bundle_file" "nightly/$(basename "$bundle_file")"done- uploadToSpaces "target/latest-sha" "latest-sha-linux-deb"+ upload_to_blob_store $bucket_name "target/latest-sha" "nightly/latest-sha-linux-deb";;*)echo "Error: Unknown target '$target'"