Files
GoTunnel-Plugins/scripts/sign-all.sh
Flik dd52c48351 feat: add signtool to plugin repository
- Migrate signing tool from GoTunnel main project
- Self-contained, no external dependencies
- Updated CI workflow to build locally
2025-12-29 19:05:56 +08:00

50 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -e
KEY_FILE="$1"
if [ -z "$KEY_FILE" ]; then
echo "Usage: $0 <private-key-file>"
exit 1
fi
if [ ! -f "$KEY_FILE" ]; then
echo "Error: Key file not found: $KEY_FILE"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
SIGNTOOL="$REPO_ROOT/signtool"
# 如果 signtool 不存在,尝试构建
if [ ! -f "$SIGNTOOL" ]; then
echo "Building signtool..."
cd "$REPO_ROOT"
go build -o signtool ./tools/signtool
fi
cd "$REPO_ROOT"
for manifest in plugins/*/manifest.json; do
[ -f "$manifest" ] || continue
dir=$(dirname "$manifest")
name=$(jq -r '.name' "$manifest")
version=$(jq -r '.version' "$manifest")
plugin_file="$dir/plugin.js"
if [ ! -f "$plugin_file" ]; then
echo "Warning: $plugin_file not found, skipping"
continue
fi
echo "Signing: $name v$version"
"$SIGNTOOL" sign -key "$KEY_FILE" \
-name "$name" \
-version "$version" \
"$plugin_file"
done
echo "Done!"