feat: add one-click dist release script

This commit is contained in:
袁震
2026-04-06 14:14:54 +08:00
parent e83bb70c9c
commit e812cb67de
2 changed files with 46 additions and 3 deletions
+9 -3
View File
@@ -1,4 +1,4 @@
# gitea-shunt-rules # shunt-rules-builder
基于 **Surge 单源** 的规则生成器: 基于 **Surge 单源** 的规则生成器:
@@ -27,7 +27,7 @@
## 快速开始 ## 快速开始
```bash ```bash
cd /Users/yuan/Desktop/workspaces/docker/pve/gitea-shunt-rules cd /Users/yuan/Desktop/workspaces/docker/pve/shunt-rules-builder
``` ```
1. 同步上游 Surge 全量源到本地缓存: 1. 同步上游 Surge 全量源到本地缓存:
@@ -48,6 +48,12 @@ python3 main.py --config config.json
python3 main.py --config config.json --names Apple,YouTube python3 main.py --config config.json --names Apple,YouTube
``` ```
4. 一键发布 `dist/` 到 release 仓库:
```bash
bash scripts/release_dist.sh
```
## 配置说明 ## 配置说明
默认配置文件:`config.json`(已启用本地源模式)。 默认配置文件:`config.json`(已启用本地源模式)。
@@ -117,7 +123,7 @@ python3 main.py --config config.json --names Apple,YouTube
## 目录结构 ## 目录结构
```text ```text
gitea-shunt-rules/ shunt-rules-builder/
├── main.py ├── main.py
├── config.json ├── config.json
├── config.example.toml ├── config.example.toml
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
DIST_DIR="${DIST_DIR:-${REPO_ROOT}/dist}"
RELEASE_REPO_URL="${RELEASE_REPO_URL:-https://git.halonice.com/yuanzhen869/shunt-rules-release.git}"
TARGET_BRANCH="${TARGET_BRANCH:-main}"
COMMIT_MESSAGE="${COMMIT_MESSAGE:-chore: release dist}"
if [[ ! -d "${DIST_DIR}" ]]; then
echo "dist directory not found: ${DIST_DIR}" >&2
exit 1
fi
tmp_dir="$(mktemp -d)"
cleanup() {
rm -rf "${tmp_dir}"
}
trap cleanup EXIT
work_dir="${tmp_dir}/release"
git clone --branch "${TARGET_BRANCH}" --single-branch "${RELEASE_REPO_URL}" "${work_dir}" >/dev/null
find "${work_dir}" -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
rsync -a "${DIST_DIR}/" "${work_dir}/"
cd "${work_dir}"
git add -A
if git diff --cached --quiet; then
echo "no changes in dist, skip release"
exit 0
fi
git -c user.name="shunt-rules-bot" -c user.email="shunt-rules-bot@local" commit -m "${COMMIT_MESSAGE}" >/dev/null
git push origin "${TARGET_BRANCH}"
echo "release pushed to ${RELEASE_REPO_URL} (${TARGET_BRANCH})"