Files
msksbr a3a268250b build: add artifact collection and Arch Linux packaging scripts
Introduce scripts to collect Tauri build artifacts across platforms and
generate a pacman package for Arch Linux. Update .gitignore to exclude
the releases directory and reorder existing entries.
2026-05-26 15:44:57 +08:00

141 lines
4.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(dirname "$SCRIPT_DIR")"
VERSION=$(jq -r '.version' "$ROOT/src-tauri/tauri.conf.json")
OUT_DIR="$ROOT/releases/$VERSION"
PKG="bookmgr-client"
# ---------------------------------------------------------------
# 准备输出目录
# ---------------------------------------------------------------
rm -rf "$OUT_DIR"
mkdir -p "$OUT_DIR"
echo "==> 收集 $PKG v$VERSION 产物 → $OUT_DIR"
# ---------------------------------------------------------------
# Web — 从 dist/ 打 tar.gz 和 zip
# ---------------------------------------------------------------
DIST="$ROOT/dist"
if [[ -d "$DIST" ]] && [[ -f "$DIST/index.html" ]]; then
TARBALL="$OUT_DIR/${PKG}-${VERSION}-web.tar.gz"
echo " [web] $TARBALL"
tar -czf "$TARBALL" -C "$DIST" .
ZIPBALL="$OUT_DIR/${PKG}-${VERSION}-web.zip"
echo " [web] $ZIPBALL"
(cd "$DIST" && zip -qr "$ZIPBALL" .)
else
echo " [web] 跳过(dist/ 未就绪,请先运行 pnpm build"
fi
# ---------------------------------------------------------------
# Linux — AppImage / deb / rpm / pacman
# ---------------------------------------------------------------
BUNDLE="$ROOT/src-tauri/target/release/bundle"
if [[ -d "$BUNDLE/appimage" ]]; then
SRC=$(echo "$BUNDLE/appimage/${PKG}_"*_amd64.AppImage)
if [[ -f "$SRC" ]]; then
DST="$OUT_DIR/${PKG}-${VERSION}-linux-amd64.AppImage"
echo " [appimage] $DST"
cp "$SRC" "$DST"
fi
fi
if [[ -d "$BUNDLE/deb" ]]; then
SRC=$(echo "$BUNDLE/deb/${PKG}_"*_amd64.deb)
if [[ -f "$SRC" ]]; then
DST="$OUT_DIR/${PKG}-${VERSION}-linux-amd64.deb"
echo " [deb] $DST"
cp "$SRC" "$DST"
fi
fi
if [[ -d "$BUNDLE/rpm" ]]; then
SRC=$(echo "$BUNDLE/rpm/${PKG}-"*x86_64.rpm)
if [[ -f "$SRC" ]]; then
DST="$OUT_DIR/${PKG}-${VERSION}-linux-x86_64.rpm"
echo " [rpm] $DST"
cp "$SRC" "$DST"
fi
fi
if [[ -d "$BUNDLE/pacman" ]]; then
for f in "$BUNDLE/pacman/${PKG}-"*.pkg.tar.zst; do
[[ -f "$f" ]] || continue
base=$(basename "$f")
# bookmgr-client-0.1.0-1-x86_64.pkg.tar.zst → bookmgr-client-0.1.0-linux-x86_64.pkg.tar.zst
newname=$(echo "$base" | sed -E 's/-1-(x86_64|aarch64)/-linux-\1/')
DST="$OUT_DIR/$newname"
echo " [pacman] $DST"
cp "$f" "$DST"
done
fi
# ---------------------------------------------------------------
# Android — APK
# ---------------------------------------------------------------
APK_DIR="$ROOT/src-tauri/gen/android/app/build/outputs/apk"
if [[ -d "$APK_DIR" ]]; then
for arch in arm64 x86_64 universal; do
SRC="$APK_DIR/$arch/release/app-${arch}-release.apk"
if [[ -f "$SRC" ]]; then
DST="$OUT_DIR/${PKG}-${VERSION}-android-${arch}.apk"
echo " [apk] $DST"
cp "$SRC" "$DST"
fi
done
fi
# ---------------------------------------------------------------
# Windows — msi / nsis
# ---------------------------------------------------------------
if [[ -d "$BUNDLE/msi" ]]; then
for f in "$BUNDLE/msi/${PKG}_"*.msi; do
[[ -f "$f" ]] || continue
base=$(basename "$f")
# bookmgr-client_0.1.0_x64_en-US.msi → bookmgr-client-0.1.0-windows-x86_64.msi
newname=$(echo "$base" | sed -E 's/_/ /g; s/ /-/g; s/x64/x86_64/; s/en-US-//')
newname="${PKG}-${VERSION}-windows-${newname#${PKG}-${VERSION}-}"
DST="$OUT_DIR/$newname"
echo " [msi] $DST"
cp "$f" "$DST"
done
fi
if [[ -d "$BUNDLE/nsis" ]]; then
for f in "$BUNDLE/nsis/${PKG}_"*.exe; do
[[ -f "$f" ]] || continue
base=$(basename "$f")
newname=$(echo "$base" | sed -E 's/_/ /g; s/ /-/g; s/x64/x86_64/; s/en-US-//')
newname="${PKG}-${VERSION}-windows-${newname#${PKG}-${VERSION}-}"
DST="$OUT_DIR/$newname"
echo " [nsis] $DST"
cp "$f" "$DST"
done
fi
# ---------------------------------------------------------------
# macOS — dmg
# ---------------------------------------------------------------
if [[ -d "$BUNDLE/dmg" ]]; then
for f in "$BUNDLE/dmg/${PKG}_"*.dmg; do
[[ -f "$f" ]] || continue
base=$(basename "$f")
newname=$(echo "$base" | sed -E 's/_/ /g; s/ /-/g; s/x64/x86_64/; s/aarch64/arm64/')
newname="${PKG}-${VERSION}-macos-${newname#${PKG}-${VERSION}-}"
DST="$OUT_DIR/$newname"
echo " [dmg] $DST"
cp "$f" "$DST"
done
fi
# ---------------------------------------------------------------
echo ""
echo "==> 完成,共 $(find "$OUT_DIR" -maxdepth 1 -type f | wc -l) 个文件:"
ls -lh "$OUT_DIR"