Files
Garfield 55e6303d0a 🔧 (linguoland): 对齐书源仓库的发布骨架
许可证、忽略规则、打包脚本和 Gitea 发版流程与其他书源一致。
2026-11-27 00:51:41 +08:00

26 lines
1.1 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/sh
# 打包本仓库的书源插件:moonsource-<名字>.koplugin-<VERSION>.zip,同时生成 SHA256SUMS。
# 用法:tools/package.sh <VERSION> [OUT_DIR] (OUT_DIR 默认 dist/)
# 打包时把 <包名>/version.lua 里的版本占位符换成发布版本;剔除 *.md、.DS_Store、*~。
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="${1:?用法:tools/package.sh <VERSION> [OUT_DIR]}"
OUT="${2:-$ROOT/dist}"
case "$OUT" in /*) ;; *) OUT="$PWD/$OUT" ;; esac
NAME="$(cd "$ROOT" && ls -d moonsource-*.koplugin | head -n 1)"
[ -f "$ROOT/$NAME/main.lua" ] || { echo "找不到插件目录:$NAME" >&2; exit 1; }
PKG="$(echo "${NAME%.koplugin}" | tr - _)"
mkdir -p "$OUT"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
rsync -a --exclude '*.md' --exclude '.DS_Store' --exclude '*~' "$ROOT/$NAME/" "$STAGE/$NAME/"
sed "s/@VERSION@/$VERSION/" "$ROOT/$NAME/$PKG/version.lua" > "$STAGE/$NAME/$PKG/version.lua"
ZIP="$OUT/$NAME-$VERSION.zip"
rm -f "$ZIP"
(cd "$STAGE" && zip -qr "$ZIP" "$NAME")
echo "Packaged $ZIP"
(cd "$OUT" && { command -v sha256sum >/dev/null && sha256sum ./*.zip || shasum -a 256 ./*.zip; } | sed 's# \./# #' > SHA256SUMS)