Files
2026-07-16 01:03:16 +08:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(dirname "$SCRIPT_DIR")"
SING_BOX="$ROOT/works/sing-box"
REV_FILE="$ROOT/works/rev"
# defaults
REPO_URL="https://git.sfclub.cc/icybear/sing-box.git"
if [ ! -z "$DEPLOY_TOKEN" ]; then
git config --global user.name imabot
git config --global user.email icybear+ci@sab.ee
fi
UPSTREAM_BRANCH="testing"
CONFIG="$ROOT/works/config"
if [ -f "$CONFIG" ]; then
. "$CONFIG"
fi
if [ -d "$SING_BOX/.git" ]; then
echo "Updating sing-box..."
git -C "$SING_BOX" fetch --all
if [ -n "$UPSTREAM_BRANCH" ]; then
git -C "$SING_BOX" checkout "$UPSTREAM_BRANCH"
fi
git -C "$SING_BOX" pull
else
echo "Cloning sing-box..."
if [ -n "$UPSTREAM_BRANCH" ]; then
git clone -b "$UPSTREAM_BRANCH" "$REPO_URL" "$SING_BOX"
else
git clone "$REPO_URL" "$SING_BOX"
fi
fi
REV="$(git -C "$SING_BOX" rev-parse HEAD)"
echo "$REV" > "$REV_FILE"
echo "Done. Version: $(git -C "$SING_BOX" describe --tags --always 2>/dev/null || echo "$REV")"
echo "Stored rev: $REV"