CI / Formatação e clippy (push) Successful in 1m9s
CI / Auditoria de dependências (push) Successful in 12s
CI / Testes (Linux) (push) Successful in 1m34s
Release / Cria a release (push) Successful in 5s
CI / Compila o app desktop (Linux) (push) Successful in 1m36s
Release / CLI (linux-aarch64) (push) Successful in 1m23s
Release / CLI (linux-x86_64) (push) Successful in 1m40s
Release / App desktop (linux-aarch64) (push) Successful in 7m32s
Release / App desktop (linux-x86_64) (push) Failing after 9m5s
Release / App desktop (windows) (push) Failing after 6m20s
147 lines
6.7 KiB
Bash
Executable File
147 lines
6.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compila o app desktop (Tauri) e deixa os pacotes em dist-gui/, com os nomes
|
|
# que a release usa.
|
|
#
|
|
# scripts/build-gui.sh linux # AppImage e .deb; precisa de uma máquina Linux com os pacotes do Tauri
|
|
# scripts/build-gui.sh windows # instalador NSIS, compilado a partir do Linux
|
|
#
|
|
# O Windows usa cargo-xwin (SDK do Windows baixado na hora) e o NSIS, que o Tauri
|
|
# documenta como compilação cruzada experimental. Precisa de: nsis, lld, llvm,
|
|
# clang e `cargo install cargo-xwin`. O .msi não sai daqui (o WiX é só do Windows).
|
|
# `scripts/build-gui.sh windows-docker` roda o mesmo num container, sem instalar nada.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
platform=${1:?uso: build-gui.sh <linux|linux-x86_64|linux-aarch64|windows|windows-docker>}
|
|
tauri() { npx --yes @tauri-apps/cli@2 "$@"; }
|
|
|
|
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ] && [ -f "$HOME/.tauri/sabia-updater.key" ]; then
|
|
export TAURI_SIGNING_PRIVATE_KEY="$(cat "$HOME/.tauri/sabia-updater.key")"
|
|
[ -f "$HOME/.tauri/sabia-updater.pass" ] && export TAURI_SIGNING_PRIVATE_KEY_PASSWORD="$(cat "$HOME/.tauri/sabia-updater.pass")"
|
|
fi
|
|
|
|
if [ "$platform" = windows-docker ]; then
|
|
docker volume create sabia-cargo >/dev/null
|
|
docker volume create sabia-rustup >/dev/null
|
|
mkdir -p dist-gui
|
|
exec docker run --rm -v "$PWD":/src -v sabia-cargo:/root/.cargo -v sabia-rustup:/root/.rustup \
|
|
-w /src -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" \
|
|
-e TAURI_SIGNING_PRIVATE_KEY -e TAURI_SIGNING_PRIVATE_KEY_PASSWORD \
|
|
ubuntu:24.04 bash -c '
|
|
set -e
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update -qq
|
|
apt-get install -y -qq curl ca-certificates build-essential pkg-config nsis lld llvm clang nodejs npm unzip >/dev/null
|
|
[ -x /root/.cargo/bin/rustup ] || curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal >/dev/null
|
|
export PATH=/root/.cargo/bin:$PATH
|
|
command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked
|
|
scripts/build-gui.sh windows
|
|
chown -R "$HOST_UID:$HOST_GID" dist-gui apps/gui/src-tauri/target 2>/dev/null || true'
|
|
fi
|
|
|
|
rm -rf dist-gui
|
|
mkdir -p dist-gui
|
|
cd apps/gui/src-tauri
|
|
|
|
# Os ícones derivados do original não ficam todos no repositório.
|
|
[ -f icons/icon.ico ] || tauri icon icons/source.png -o icons
|
|
|
|
tauri_blob_cache="$HOME/.cache/tauri"
|
|
if [ -d /opt/hostedtoolcache ] && [ -w /opt/hostedtoolcache ]; then
|
|
tauri_blob_cache="/opt/hostedtoolcache/tauri-tools"
|
|
fi
|
|
mkdir -p "$tauri_blob_cache" "$HOME/.cache/tauri"
|
|
|
|
fetch_cached_tool() {
|
|
local name=$1 url=$2 patch_elf=${3:-0}
|
|
local cached="$tauri_blob_cache/$name"
|
|
if [ ! -s "$cached" ]; then
|
|
local tmp="$cached.tmp.$$"
|
|
curl -fsSL "$url" -o "$tmp"
|
|
if [ "$patch_elf" = 1 ]; then
|
|
dd if=/dev/zero of="$tmp" bs=1 count=3 seek=8 conv=notrunc 2>/dev/null
|
|
fi
|
|
chmod +x "$tmp"
|
|
mv -f "$tmp" "$cached"
|
|
fi
|
|
if [ "$cached" != "$HOME/.cache/tauri/$name" ]; then
|
|
cp -f "$cached" "$HOME/.cache/tauri/$name"
|
|
chmod +x "$HOME/.cache/tauri/$name"
|
|
fi
|
|
}
|
|
|
|
case "$platform" in
|
|
linux|linux-aarch64)
|
|
bundle="${CARGO_TARGET_DIR:-target}/release/bundle"
|
|
rm -rf "$bundle/appimage" "$bundle/deb"
|
|
tauri build --bundles appimage,deb
|
|
cp "$bundle"/appimage/*.AppImage "$bundle"/deb/*.deb ../../../dist-gui/
|
|
# O atualizador do Tauri (quando o projeto usa) precisa do .sig ao lado.
|
|
cp "$bundle"/appimage/*.AppImage.sig ../../../dist-gui/ 2>/dev/null || true
|
|
;;
|
|
linux-x86_64)
|
|
if [ "$(uname -m)" = x86_64 ]; then
|
|
bundle="${CARGO_TARGET_DIR:-target}/release/bundle"
|
|
rm -rf "$bundle/appimage" "$bundle/deb"
|
|
tauri build --bundles appimage,deb
|
|
else
|
|
rustup target add x86_64-unknown-linux-gnu >/dev/null
|
|
mkdir -p /tmp/x86_64-cross-tools "$HOME/.cache/tauri"
|
|
cat >/tmp/x86_64-cross-tools/ldd <<'EOF'
|
|
#!/usr/bin/env bash
|
|
exec qemu-x86_64 /lib64/ld-linux-x86-64.so.2 --list "$@"
|
|
EOF
|
|
chmod +x /tmp/x86_64-cross-tools/ldd
|
|
ln -sf /usr/bin/x86_64-linux-gnu-strip /tmp/x86_64-cross-tools/strip
|
|
for tool_rel in glib-2.0/gio-querymodules gdk-pixbuf-2.0/gdk-pixbuf-query-loaders libgtk-3-0t64/gtk-query-immodules-3.0 libgtk-3-0/gtk-query-immodules-3.0; do
|
|
if [ -x "/usr/lib/x86_64-linux-gnu/$tool_rel" ]; then
|
|
tname=$(basename "$tool_rel")
|
|
printf '#!/usr/bin/env bash\nexec qemu-x86_64 "/usr/lib/x86_64-linux-gnu/%s" "$@"\n' "$tool_rel" >"/tmp/x86_64-cross-tools/$tname"
|
|
chmod +x "/tmp/x86_64-cross-tools/$tname"
|
|
fi
|
|
done
|
|
fetch_cached_tool "linuxdeploy-07333c6-aarch64.AppImage" \
|
|
"https://github.com/tauri-apps/binary-releases/releases/download/linuxdeploy-07333c6/linuxdeploy-aarch64.AppImage" 1
|
|
fetch_cached_tool "linuxdeploy-plugin-appimage.AppImage" \
|
|
"https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-aarch64.AppImage" 1
|
|
fetch_cached_tool "runtime-x86_64" \
|
|
"https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64" 0
|
|
cat >"$HOME/.cache/tauri/linuxdeploy-07333c6-x86_64.AppImage" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
export ARCH=x86_64
|
|
export NO_STRIP=true
|
|
export APPIMAGE_EXTRACT_AND_RUN=1
|
|
export LDAI_RUNTIME_FILE="$HOME/.cache/tauri/runtime-x86_64"
|
|
export LD_GTK_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
|
|
export DEB_HOST_MULTIARCH=x86_64-linux-gnu
|
|
export PKG_CONFIG_ALLOW_CROSS=1
|
|
export PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
|
|
export PATH="/tmp/x86_64-cross-tools:$PATH"
|
|
exec "$HOME/.cache/tauri/linuxdeploy-07333c6-aarch64.AppImage" "$@"
|
|
EOF
|
|
chmod +x "$HOME/.cache/tauri/linuxdeploy-07333c6-x86_64.AppImage"
|
|
export PKG_CONFIG_ALLOW_CROSS=1
|
|
export PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
|
|
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc
|
|
export CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc
|
|
export CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++
|
|
bundle="${CARGO_TARGET_DIR:-target}/x86_64-unknown-linux-gnu/release/bundle"
|
|
rm -rf "$bundle/appimage" "$bundle/deb"
|
|
tauri build --target x86_64-unknown-linux-gnu --bundles appimage,deb
|
|
fi
|
|
cp "$bundle"/appimage/*.AppImage "$bundle"/deb/*.deb ../../../dist-gui/
|
|
cp "$bundle"/appimage/*.AppImage.sig ../../../dist-gui/ 2>/dev/null || true
|
|
;;
|
|
windows)
|
|
rustup target add x86_64-pc-windows-msvc >/dev/null
|
|
bundle="${CARGO_TARGET_DIR:-target}/x86_64-pc-windows-msvc/release/bundle/nsis"
|
|
rm -rf "$bundle"
|
|
tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc --bundles nsis
|
|
cp "$bundle"/*-setup.exe ../../../dist-gui/
|
|
cp "$bundle"/*-setup.exe.sig ../../../dist-gui/ 2>/dev/null || true
|
|
;;
|
|
*) echo "plataforma desconhecida: $platform" >&2; exit 2 ;;
|
|
esac
|
|
|
|
ls -1 ../../../dist-gui
|