Add script to package Linux binary into archive (#11165)
Release Notes: - N/A
This commit is contained in:
parent
73d0600ad2
commit
d743c19fe2
7 changed files with 92 additions and 105 deletions
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
|
@ -260,15 +260,13 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
bundle-deb:
|
bundle-linux:
|
||||||
name: Create a *.deb Linux bundle
|
name: Create a Linux bundle
|
||||||
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
|
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
|
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
|
||||||
needs: [linux_tests]
|
needs: [linux_tests]
|
||||||
env:
|
env:
|
||||||
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
|
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:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -312,19 +310,18 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO linux : Find a way to add licenses to the final bundle
|
- name: Generate license file
|
||||||
# - name: Generate license file
|
run: script/generate-licenses
|
||||||
# run: script/generate-licenses
|
|
||||||
|
|
||||||
- name: Create Linux *.deb bundle
|
- name: Create and upload Linux .tar.gz bundle
|
||||||
run: script/bundle-linux
|
run: script/bundle-linux
|
||||||
|
|
||||||
- name: Upload app bundle to workflow run if main branch or specific label
|
- name: Upload Linux bundle to workflow run if main branch or specific label
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
|
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
|
||||||
with:
|
with:
|
||||||
name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.deb
|
name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
|
||||||
path: target/release/*.deb
|
path: zed-*.tar.gz
|
||||||
|
|
||||||
# TODO linux : make it stable enough to be uploaded as a release
|
# TODO linux : make it stable enough to be uploaded as a release
|
||||||
# - uses: softprops/action-gh-release@v1
|
# - uses: softprops/action-gh-release@v1
|
||||||
|
|
11
.github/workflows/release_nightly.yml
vendored
11
.github/workflows/release_nightly.yml
vendored
|
@ -94,7 +94,7 @@ jobs:
|
||||||
run: script/upload-nightly macos
|
run: script/upload-nightly macos
|
||||||
|
|
||||||
bundle-deb:
|
bundle-deb:
|
||||||
name: Create a *.deb Linux bundle
|
name: Create a Linux *.tar.gz bundle
|
||||||
if: github.repository_owner == 'zed-industries'
|
if: github.repository_owner == 'zed-industries'
|
||||||
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
|
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
|
||||||
needs: tests
|
needs: tests
|
||||||
|
@ -125,12 +125,11 @@ jobs:
|
||||||
echo "Publishing version: ${version} on release channel nightly"
|
echo "Publishing version: ${version} on release channel nightly"
|
||||||
echo "nightly" > crates/zed/RELEASE_CHANNEL
|
echo "nightly" > crates/zed/RELEASE_CHANNEL
|
||||||
|
|
||||||
# TODO linux : find a way to add licenses to the final bundle
|
- name: Generate license file
|
||||||
# - name: Generate license file
|
run: script/generate-licenses
|
||||||
# run: script/generate-licenses
|
|
||||||
|
|
||||||
- name: Create Linux *.deb bundle
|
- name: Create Linux .tar.gz bundle
|
||||||
run: script/bundle-linux
|
run: script/bundle-linux
|
||||||
|
|
||||||
- name: Upload Zed Nightly
|
- name: Upload Zed Nightly
|
||||||
run: script/upload-nightly linux-deb
|
run: script/upload-nightly linux-targz
|
||||||
|
|
13
crates/zed/resources/zed.desktop
Normal file
13
crates/zed/resources/zed.desktop
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Type=Application
|
||||||
|
Name=Zed
|
||||||
|
GenericName=Text Editor
|
||||||
|
Comment=A high-performance, multiplayer code editor.
|
||||||
|
TryExec=zed
|
||||||
|
StartupNotify=true
|
||||||
|
Exec=zed
|
||||||
|
Icon=zed
|
||||||
|
Categories=TextEditor;Development;IDE;
|
||||||
|
Keywords=zed;
|
||||||
|
MimeType=text/plain;
|
|
@ -2,32 +2,20 @@
|
||||||
|
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
build_flag="--release"
|
# Function for displaying help info
|
||||||
target_dir="release"
|
|
||||||
bundle_name=""
|
|
||||||
zed_crate="zed"
|
|
||||||
|
|
||||||
|
|
||||||
help_info() {
|
help_info() {
|
||||||
echo "
|
echo "
|
||||||
Usage: ${0##*/} [options] [bundle_name]
|
Usage: ${0##*/} [options]
|
||||||
Build the application bundle for Linux.
|
Build a release .tar.gz for Linux.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d Compile in debug mode
|
-h Display this help and exit.
|
||||||
-h Display this help and exit
|
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'dh' flag
|
while getopts 'h' flag
|
||||||
do
|
do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
d)
|
|
||||||
export CARGO_INCREMENTAL=true
|
|
||||||
export CARGO_BUNDLE_SKIP_BUILD=true
|
|
||||||
build_flag="";
|
|
||||||
target_dir="debug"
|
|
||||||
;;
|
|
||||||
h)
|
h)
|
||||||
help_info
|
help_info
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -35,68 +23,54 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
if [[ $# -gt 0 ]]; then
|
|
||||||
if [ "$1" ]; then
|
|
||||||
bundle_name=$1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
export ZED_BUNDLE=true
|
export ZED_BUNDLE=true
|
||||||
|
|
||||||
cargo_bundle_version=$(cargo -q bundle --help 2>&1 | head -n 1 || echo "")
|
channel=$(<crates/zed/RELEASE_CHANNEL)
|
||||||
if [ "$cargo_bundle_version" != "cargo-bundle v0.6.0-zed" ]; then
|
version="$(cargo metadata --no-deps --manifest-path crates/zed/Cargo.toml --offline --format-version=1 | jq -r '.packages | map(select(.name == "zed"))[0].version')"
|
||||||
cargo install cargo-bundle --git https://github.com/zed-industries/cargo-bundle.git --branch zed-deploy
|
commit=$(git rev-parse HEAD | cut -c 1-7)
|
||||||
|
|
||||||
|
version_info=$(rustc --version --verbose)
|
||||||
|
host_line=$(echo "$version_info" | grep host)
|
||||||
|
target_triple=${host_line#*: }
|
||||||
|
|
||||||
|
# Build binary in release mode
|
||||||
|
cargo build --release --target "${target_triple}" --package zed
|
||||||
|
|
||||||
|
# Strip the binary of all debug symbols
|
||||||
|
# Later, we probably want to do something like this: https://github.com/GabrielMajeri/separate-symbols
|
||||||
|
strip "target/${target_triple}/release/Zed"
|
||||||
|
|
||||||
|
# Move everything that should end up in the final package
|
||||||
|
# into a temp directory.
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
|
|
||||||
|
# Binary
|
||||||
|
mkdir "${temp_dir}/bin"
|
||||||
|
cp "target/${target_triple}/release/Zed" "${temp_dir}/bin/zed"
|
||||||
|
|
||||||
|
# Icons
|
||||||
|
mkdir -p "${temp_dir}/share/icons/hicolor/512x512/apps"
|
||||||
|
cp "crates/zed/resources/app-icon-nightly.png" "${temp_dir}/share/icons/hicolor/512x512/apps/zed.png"
|
||||||
|
mkdir -p "${temp_dir}/share/icons/hicolor/1024x1024/apps"
|
||||||
|
cp "crates/zed/resources/app-icon-nightly@2x.png" "${temp_dir}/share/icons/hicolor/1024x1024/apps/zed.png"
|
||||||
|
|
||||||
|
# .desktop
|
||||||
|
mkdir -p "${temp_dir}/share/applications"
|
||||||
|
cp "crates/zed/resources/zed.desktop" "${temp_dir}/share/applications/zed.desktop"
|
||||||
|
|
||||||
|
# Licenses
|
||||||
|
cp "assets/licenses.md" "${temp_dir}/licenses.md"
|
||||||
|
|
||||||
|
# Create archive out of everything that's in the temp directory
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$channel" == "nightly" ]]; then
|
||||||
|
archive="zed-${channel}-${target_triple}.tar.gz"
|
||||||
|
elif [[ "$channel" == "dev" ]]; then
|
||||||
|
archive="zed-${channel}-${commit}-${target_triple}.tar.gz"
|
||||||
|
else
|
||||||
|
archive="zed-${version}-${target_triple}.tar.gz"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Compiling zed binaries"
|
rm -rf "${archive}"
|
||||||
cargo build ${build_flag} --package ${zed_crate} --package cli
|
tar -czvf $archive -C ${temp_dir} .
|
||||||
|
|
||||||
echo "Creating application bundle"
|
|
||||||
pushd crates/${zed_crate}
|
|
||||||
channel=$(<RELEASE_CHANNEL)
|
|
||||||
cp Cargo.toml Cargo.toml.backup
|
|
||||||
sed \
|
|
||||||
-i.backup -e \
|
|
||||||
"s/package.metadata.bundle-${channel}/package.metadata.bundle/" \
|
|
||||||
Cargo.toml
|
|
||||||
|
|
||||||
# TODO linux `zed_cli` does not get into this bundle despite being built
|
|
||||||
bundle_path=$(cargo bundle ${build_flag} --select-workspace-root | xargs)
|
|
||||||
|
|
||||||
mv Cargo.toml.backup Cargo.toml
|
|
||||||
popd
|
|
||||||
|
|
||||||
# For nightly, cut off the version out of the bundle name that `cargo bundle` always adds.
|
|
||||||
if [ "$channel" == "nightly" ]; then
|
|
||||||
version="$(cargo metadata --no-deps --manifest-path crates/zed/Cargo.toml --offline --format-version=1 | jq -r '.packages | map(select(.name == "zed"))[0].version')"
|
|
||||||
version_less_bundle_path=$(echo "$bundle_path" | sed "s/_$version//")
|
|
||||||
mv "$bundle_path" "$version_less_bundle_path"
|
|
||||||
bundle_path="$version_less_bundle_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO linux
|
|
||||||
# Other Linux systems will need a different set of manipulations + a way to know which ones to do.
|
|
||||||
# If bundle_name is not set or empty, use the basename of $bundle_path
|
|
||||||
if [ -z "${bundle_name}" ]; then
|
|
||||||
bundle_name=$(basename "${bundle_path}")
|
|
||||||
fi
|
|
||||||
# If bundle_name doesn't end in .deb, append it
|
|
||||||
if [[ "$bundle_name" != *.deb ]]; then
|
|
||||||
bundle_name="$bundle_name.deb"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd target/
|
|
||||||
rm -rf bundle/ 2>/dev/null || true
|
|
||||||
dpkg-deb -x "${bundle_path}" bundle/
|
|
||||||
dpkg-deb --control "${bundle_path}" bundle/DEBIAN
|
|
||||||
mkdir -p bundle/usr/local/bin/
|
|
||||||
mv bundle/usr/bin/Zed "bundle/usr/local/bin/zed-$channel"
|
|
||||||
cp "${target_dir}/cli" "bundle/usr/local/bin/cli-$channel"
|
|
||||||
ln -s "/usr/local/bin/cli-$channel" "bundle/usr/local/bin/zed"
|
|
||||||
rm -rf bundle/usr/bin/
|
|
||||||
dpkg-deb -b bundle/ "${target_dir}/${bundle_name}"
|
|
||||||
bundle_path="${PWD}/${target_dir}/${bundle_name}"
|
|
||||||
popd
|
|
||||||
echo "Bundled ${bundle_path}"
|
|
||||||
|
|
|
@ -19,9 +19,12 @@ echo -e "# ###### CODE LICENSES ######\n" >> $OUTPUT_FILE
|
||||||
echo "Generating cargo licenses"
|
echo "Generating cargo licenses"
|
||||||
cargo about generate --fail -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md >> $OUTPUT_FILE
|
cargo about generate --fail -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md >> $OUTPUT_FILE
|
||||||
|
|
||||||
sed -i '' 's/"/"/g' $OUTPUT_FILE
|
|
||||||
sed -i '' 's/'/'\''/g' $OUTPUT_FILE # The ` '\'' ` thing ends the string, appends a single quote, and re-opens the string
|
sed -i.bak 's/"/"/g' $OUTPUT_FILE
|
||||||
sed -i '' 's/=/=/g' $OUTPUT_FILE
|
sed -i.bak 's/'/'\''/g' $OUTPUT_FILE # The ` '\'' ` thing ends the string, appends a single quote, and re-opens the string
|
||||||
sed -i '' 's/`/`/g' $OUTPUT_FILE
|
sed -i.bak 's/=/=/g' $OUTPUT_FILE
|
||||||
sed -i '' 's/</</g' $OUTPUT_FILE
|
sed -i.bak 's/`/`/g' $OUTPUT_FILE
|
||||||
sed -i '' 's/>/>/g' $OUTPUT_FILE
|
sed -i.bak 's/</</g' $OUTPUT_FILE
|
||||||
|
sed -i.bak 's/>/>/g' $OUTPUT_FILE
|
||||||
|
|
||||||
|
rm -rf "${OUTPUT_FILE}.bak"
|
||||||
|
|
1
script/install.sh
Normal file
1
script/install.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#!/bin/sh
|
|
@ -4,7 +4,7 @@
|
||||||
bash -euo pipefail
|
bash -euo pipefail
|
||||||
source script/lib/blob-store.sh
|
source script/lib/blob-store.sh
|
||||||
|
|
||||||
allowed_targets=("linux-deb" "macos")
|
allowed_targets=("linux-targz" "macos")
|
||||||
is_allowed_target() {
|
is_allowed_target() {
|
||||||
for val in "${allowed_targets[@]}"; do
|
for val in "${allowed_targets[@]}"; do
|
||||||
if [[ "$1" == "$val" ]]; then
|
if [[ "$1" == "$val" ]]; then
|
||||||
|
@ -40,11 +40,11 @@ case "$target" in
|
||||||
upload_to_blob_store $bucket_name "target/release/Zed.dmg" "nightly/Zed.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"
|
upload_to_blob_store $bucket_name "target/latest-sha" "nightly/latest-sha"
|
||||||
;;
|
;;
|
||||||
linux-deb)
|
linux-targz)
|
||||||
find target/release -type f -name "*.deb" -print0 | while IFS= read -r -d '' bundle_file; do
|
find . -type f -name "zed-*.tar.gz" -print0 | while IFS= read -r -d '' bundle_file; do
|
||||||
upload_to_blob_store $bucket_name "$bundle_file" "nightly/$(basename "$bundle_file")"
|
upload_to_blob_store $bucket_name "$bundle_file" "nightly/$(basename "$bundle_file")"
|
||||||
done
|
done
|
||||||
upload_to_blob_store $bucket_name "target/latest-sha" "nightly/latest-sha-linux-deb"
|
upload_to_blob_store $bucket_name "target/latest-sha" "nightly/latest-sha-linux-targz"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Unknown target '$target'"
|
echo "Error: Unknown target '$target'"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue