chore: prepare to release

This commit is contained in:
2025-08-02 13:16:24 +07:00
parent c188f12993
commit 80c649f9a0
21 changed files with 462 additions and 85 deletions

123
script/bundle-linux Executable file
View File

@@ -0,0 +1,123 @@
#!/usr/bin/env bash
set -euxo pipefail
# Function for displaying help info
help_info() {
echo "
Usage: ${0##*/} [options]
Build a release .tar.gz for Linux.
Options:
-h, --help Display this help and exit.
--flatpak Set COOP_BUNDLE_TYPE=flatpak so that this can be included in system info
"
}
# Parse all arguments manually
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
help_info
exit 0
;;
--flatpak)
export COOP_BUNDLE_TYPE=flatpak
shift
;;
--)
shift
break
;;
-*)
echo "Unknown option: $1" >&2
help_info
exit 1
;;
*)
echo "Error: Unexpected argument: $1" >&2
help_info
exit 1
;;
esac
done
export COOP_BUNDLE=true
target_dir="${CARGO_TARGET_DIR:-target}"
version="$(script/get-crate-version coop)"
# Set RELEASE_VERSION so it's compiled into GPUI and it knows about the version.
export RELEASE_VERSION="${version}"
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#*: }
musl_triple=${target_triple%-gnu}-musl
remote_server_triple=${REMOTE_SERVER_TARGET:-"${musl_triple}"}
rustup_installed=false
if command -v rustup >/dev/null 2>&1; then
rustup_installed=true
fi
export CC=$(which clang)
# Build binary in release mode
export RUSTFLAGS="${RUSTFLAGS:-} -C link-args=-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib"
cargo build --release --target "${target_triple}" --package coop
# Strip debug symbols and save them for upload to DigitalOcean
objcopy --only-keep-debug "${target_dir}/${target_triple}/release/coop" "${target_dir}/${target_triple}/release/coop.dbg"
objcopy --strip-debug "${target_dir}/${target_triple}/release/coop"
gzip -f "${target_dir}/${target_triple}/release/coop.dbg"
# Move everything that should end up in the final package
# into a temp directory.
temp_dir=$(mktemp -d)
coop_dir="${temp_dir}/coop.app"
# Binary
mkdir -p "${coop_dir}/bin" "${coop_dir}/libexec"
cp "${target_dir}/${target_triple}/release/coop" "${coop_dir}/libexec/coop"
cp "${target_dir}/${target_triple}/release/cli" "${coop_dir}/bin/coop"
# Libs
find_libs() {
ldd ${target_dir}/${target_triple}/release/coop |\
cut -d' ' -f3 |\
grep -v '\<\(libstdc++.so\|libc.so\|libgcc_s.so\|libm.so\|libpthread.so\|libdl.so\|libasound.so\)'
}
mkdir -p "${coop_dir}/lib"
rm -rf "${coop_dir}/lib/*"
cp $(find_libs) "${coop_dir}/lib"
# Icons
mkdir -p "${coop_dir}/share/icons/hicolor/512x512/apps"
cp "crates/coop/resources/icon.png" "${coop_dir}/share/icons/hicolor/512x512/apps/coop.png"
mkdir -p "${coop_dir}/share/icons/hicolor/1024x1024/apps"
cp "crates/coop/resources/icon@2x.png" "${coop_dir}/share/icons/hicolor/1024x1024/apps/coop.png"
# .desktop
export DO_STARTUP_NOTIFY="true"
export APP_CLI="coop"
export APP_ICON="coop"
export APP_ARGS="%U"
export APP_NAME="Coop"
mkdir -p "${coop_dir}/share/applications"
envsubst < "crates/coop/resources/coop.desktop.in" > "${coop_dir}/share/applications/coop.desktop"
# Create archive out of everything that's in the temp directory
arch=$(uname -m)
target="linux-${arch}"
archive="coop-${target}.tar.gz"
rm -rf "${archive}"
remove_match="coop(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz"
ls "${target_dir}/release" | grep -E ${remove_match} | xargs -d "\n" -I {} rm -f "${target_dir}/release/{}" || true
tar -czvf "${target_dir}/release/$archive" -C ${temp_dir} "coop.app"

21
script/flatpak/bundle-flatpak Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/../.."
shopt -s extglob
script/bundle-linux --flatpak
archive_match="zed(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz"
archive=$(ls "target/release" | grep -E ${archive_match})
export ARCHIVE="$archive"
export APP_ID="dev.coop.Coop"
export APP_NAME="Coop"
export BRANDING_LIGHT="#99c1f1"
export BRANDING_DARK="#1a5fb4"
export ICON_FILE="icon"
envsubst < "crates/coop/resources/flatpak/manifest-template.json" > "$APP_ID.json"
flatpak-builder --user --install --force-clean build "$APP_ID.json"
flatpak build-bundle ~/.local/share/flatpak/repo "target/release/$APP_ID.flatpak" "$APP_ID"
echo "Created 'target/release/$APP_ID.flatpak'"

9
script/flatpak/deps Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
arch=$(arch)
fd_version=23.08
flatpak install -y --user org.freedesktop.Platform/${arch}/${fd_version}
flatpak install -y --user org.freedesktop.Sdk/${arch}/${fd_version}
flatpak install -y --user org.freedesktop.Sdk.Extension.rust-stable/${arch}/${fd_version}

0
script/freebsd Normal file → Executable file
View File

17
script/get-crate-version Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eu
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <crate_name>" >&2
exit 1
fi
CRATE_NAME=$1
cargo metadata \
--no-deps \
--format-version=1 \
| jq \
--raw-output \
".packages[] | select(.name == \"${CRATE_NAME}\") | .version"

27
script/snap-build Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euxo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <release_version>"
exit 1
fi
mkdir -p snap/gui
export DO_STARTUP_NOTIFY="true"
export APP_NAME="Coop"
export APP_CLI="coop"
export APP_ICON="\${SNAP}/meta/gui/coop.png"
export APP_ARGS="%U"
envsubst < "crates/coop/resources/coop.desktop.in" > "snap/gui/coop.desktop"
cp "crates/coop/resources/icon.png" "snap/gui/coop.png"
RELEASE_VERSION="$1" envsubst < crates/coop/resources/snap/snapcraft.yaml.in > snap/snapcraft.yaml
# Clean seems to be needed to actually check that the snapcraft.yaml
# works. For example, when a `stage-package` is removed, it will
# still remain on rebuild.
snapcraft clean
snapcraft

25
script/snap-try Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# This script is intended to be run after `snap-build`.
#
# It expects a version to be passed as the first argument, and expects
# the built `.snap` for that version to be in the current directory.
#
# This will uninstall the current `coop` snap, replacing it with a snap
# that directly uses the `snap/unpacked` directory.
set -euxo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <release_version>"
exit 1
fi
# Rerun as root
[ "$UID" -eq 0 ] || exec sudo bash -e "$0" "$@"
snap remove coop || true
mkdir -p snap
rm -rf snap/unpacked
unsquashfs -dest snap/unpacked "coop_$1_amd64.snap"
snap try --classic snap/unpacked