feat: 补丁推送脚本 push-hotfix.sh + README文档
This commit is contained in:
@@ -1,18 +1,44 @@
|
|||||||
# OTA 文件夹
|
# OTA 热更新目录
|
||||||
|
|
||||||
此目录存放 manifest 文件。manifest-stable.json 是 CI 构建时动态生成的产物,
|
## 文件说明
|
||||||
也提交到仓库通过 raw URL 供客户端拉取。
|
|
||||||
|
|
||||||
## 文件
|
| 文件 | 用途 |
|
||||||
|
|------|------|
|
||||||
|
| `version.txt` | v5 嵌入式初始化——格式: `版本\|URL\|SHA256` |
|
||||||
|
| `h5-manifest-stable.json` | 发行渠道(stable)——格式: `{latest, min_version, url, sha256}` |
|
||||||
|
| `h5-manifest-beta.json` | 测试渠道(beta) |
|
||||||
|
| `h5-manifest-nightly.json` | 开发渠道(nightly) |
|
||||||
|
| `h5/index-vN.html` | 可下载的热更新页面 |
|
||||||
|
|
||||||
- `gen-manifest.sh` — 构建后运行,计算 APK SHA256 并生成 manifest-stable.json
|
## 推送补丁
|
||||||
- `manifest-stable.json` — stable 渠道
|
|
||||||
- `manifest-beta.json` — beta 渠道
|
|
||||||
- `manifest-nightly.json` — nightly 渠道
|
|
||||||
|
|
||||||
## 流程
|
```bash
|
||||||
|
# 更新所有渠道到 v7
|
||||||
|
cd ota
|
||||||
|
bash push-hotfix.sh 7 all
|
||||||
|
|
||||||
|
# 只更新 nightly 渠道
|
||||||
|
bash push-hotfix.sh 7 nightly
|
||||||
|
|
||||||
|
# 手动推送
|
||||||
|
git add ota/
|
||||||
|
git commit -m "hotfix: v7"
|
||||||
|
git push
|
||||||
```
|
```
|
||||||
CI 构建 APK → ./ota/gen-manifest.sh → git push manifest-stable.json
|
|
||||||
手机 App → raw URL 拉取 manifest → 比较版本 → 下载 APK → SHA256 校验
|
## 格式
|
||||||
|
|
||||||
|
**h5-manifest-*.json:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"latest": "0.1.0-dav-android-6",
|
||||||
|
"min_version": "0.1.0-dav-android-5",
|
||||||
|
"url": "https://git.childish-ghost.com/.../ota/h5/index-v6.html",
|
||||||
|
"sha256": "33a16632..."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**version.txt:**
|
||||||
|
```
|
||||||
|
0.1.0-dav-android-6|https://.../ota/h5/index-v6.html|33a16632...
|
||||||
```
|
```
|
||||||
|
|||||||
79
ota/push-hotfix.sh
Normal file
79
ota/push-hotfix.sh
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# push-hotfix.sh — 推送 H5 热更新补丁到 Gitea
|
||||||
|
#
|
||||||
|
# 用法:
|
||||||
|
# ./push-hotfix.sh 7 stable # 只更新 stable 渠道
|
||||||
|
# ./push-hotfix.sh 7 all # 更新全部三个渠道
|
||||||
|
# ./push-hotfix.sh 7 beta nightly # 更新指定渠道
|
||||||
|
#
|
||||||
|
# 流程:
|
||||||
|
# 1. 创建 ota/h5/index-v{VER}.html(如果不存在则从模板生成)
|
||||||
|
# 2. 计算 SHA256
|
||||||
|
# 3. 更新 ota/h5-manifest-{CHANNEL}.json
|
||||||
|
# 4. 如果是稳定版,更新 ota/version.txt
|
||||||
|
# 5. git add + commit + push
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
VER="$1"
|
||||||
|
shift
|
||||||
|
CHANNELS=("$@")
|
||||||
|
|
||||||
|
if [ -z "$VER" ] || [ ${#CHANNELS[@]} -eq 0 ]; then
|
||||||
|
echo "用法: $0 <版本号> <渠道...>"
|
||||||
|
echo "示例: $0 7 stable beta nightly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OTA_DIR="$(dirname "$0")"
|
||||||
|
H5_DIR="$OTA_DIR/h5"
|
||||||
|
BASE_URL="https://git.childish-ghost.com/LukeMackin/Yuzu-GCA/raw/branch/main/ota"
|
||||||
|
|
||||||
|
# 1. 创建 HTML 文件(如果不存在)
|
||||||
|
HTML_FILE="$H5_DIR/index-v${VER}.html"
|
||||||
|
if [ ! -f "$HTML_FILE" ]; then
|
||||||
|
echo "→ 请手动创建 $HTML_FILE 或从 index-v6.html 复制修改"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. 计算 SHA256
|
||||||
|
SHA256=$(sha256sum "$HTML_FILE" | cut -d' ' -f1)
|
||||||
|
echo "SHA256: $SHA256"
|
||||||
|
|
||||||
|
# 3. 更新 manifest
|
||||||
|
FULL_URL="${BASE_URL}/h5/index-v${VER}.html"
|
||||||
|
|
||||||
|
for CH in "${CHANNELS[@]}"; do
|
||||||
|
if [ "$CH" = "all" ]; then
|
||||||
|
for CH in stable beta nightly; do
|
||||||
|
MANIFEST="$OTA_DIR/h5-manifest-${CH}.json"
|
||||||
|
cat > "$MANIFEST" <<EOF
|
||||||
|
{"latest":"0.1.0-dav-android-${VER}","min_version":"0.1.0-dav-android-5","url":"${FULL_URL}","sha256":"${SHA256}"}
|
||||||
|
EOF
|
||||||
|
echo " ✓ h5-manifest-${CH}.json"
|
||||||
|
done
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
MANIFEST="$OTA_DIR/h5-manifest-${CH}.json"
|
||||||
|
cat > "$MANIFEST" <<EOF
|
||||||
|
{"latest":"0.1.0-dav-android-${VER}","min_version":"0.1.0-dav-android-5","url":"${FULL_URL}","sha256":"${SHA256}"}
|
||||||
|
EOF
|
||||||
|
echo " ✓ h5-manifest-${CH}.json"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 4. 稳定版更新 version.txt
|
||||||
|
if [[ " ${CHANNELS[*]} " =~ " stable " ]] || [[ " ${CHANNELS[*]} " =~ " all " ]]; then
|
||||||
|
echo "0.1.0-dav-android-${VER}|${FULL_URL}|${SHA256}" > "$OTA_DIR/version.txt"
|
||||||
|
echo " ✓ version.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. git push
|
||||||
|
echo ""
|
||||||
|
echo "commit & push?"
|
||||||
|
read -p "(y/N) " yn
|
||||||
|
if [ "$yn" = "y" ] || [ "$yn" = "Y" ]; then
|
||||||
|
git add "$OTA_DIR"
|
||||||
|
git commit -m "hotfix: v${VER} → ${CHANNELS[*]}"
|
||||||
|
git push
|
||||||
|
echo "✓ pushed"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user