更新 OpenWrt/upload.sh
Signed-off-by: zhao <zhao@noreply.localhost>
This commit is contained in:
parent
b7b43948cc
commit
90c54de130
@ -3,30 +3,54 @@ set -e
|
||||
|
||||
# 配置参数
|
||||
REPO="oppen321/ZeroWrt-Action"
|
||||
DATE_VERSION=$(date +%Y%m%d) # 添加日期变量
|
||||
|
||||
# 1. 下载GitHub Release文件
|
||||
echo "➜ 下载GitHub Release文件..."
|
||||
|
||||
# 根据架构选择对应的tag
|
||||
if [ "$model" = "x86_64" ]; then
|
||||
RELEASE_URL="https://api.github.com/repos/oppen321/ZeroWrt-Action/git/refs/tags/OpenWrt-X86_64-24.10"
|
||||
TAG="OpenWrt-X86_64-24.10"
|
||||
elif [ "$model" = "rockchip" ]; then
|
||||
RELEASE_URL="https://api.github.com/repos/oppen321/ZeroWrt-Action/git/refs/tags/OpenWrt-Rockchip-24.10"
|
||||
TAG="OpenWrt-Rockchip-24.10"
|
||||
else
|
||||
echo "❌ 未指定有效的model参数 (x86_64 或 rockchip)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ASSETS=$(curl -sSL "$RELEASE_URL" | jq -r '.assets[] | .browser_download_url')
|
||||
# 获取release的assets
|
||||
RELEASE_URL="https://api.github.com/repos/${REPO}/releases/tags/${TAG}"
|
||||
|
||||
# 添加GitHub API认证(如果是私有仓库或避免限流)
|
||||
# TOKEN="your_github_token"
|
||||
# HEADERS=(-H "Authorization: token ${TOKEN}")
|
||||
|
||||
# 获取assets下载链接
|
||||
ASSETS=$(curl -sSL "${HEADERS[@]}" "$RELEASE_URL" | jq -r '.assets[]?.browser_download_url')
|
||||
|
||||
if [ -z "$ASSETS" ]; then
|
||||
echo "❌ 未找到对应release的assets文件"
|
||||
echo "❌ 未找到对应release的assets文件,可能原因:"
|
||||
echo " - tag名称不正确: ${TAG}"
|
||||
echo " - 仓库中没有该tag的release"
|
||||
echo " - API请求被限制(尝试添加GitHub token)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p ./downloads
|
||||
cd ./downloads
|
||||
cd ./downloads || exit 1
|
||||
|
||||
for url in $ASSETS; do
|
||||
echo "正在下载: $(basename "$url")"
|
||||
wget -q --show-progress "$url"
|
||||
done
|
||||
|
||||
rename 's/^openwrt/zerowrt-plus-$date_version/' openwrt*
|
||||
# 重命名文件
|
||||
for file in openwrt*; do
|
||||
if [ -e "$file" ]; then
|
||||
newname="zerowrt-plus-${DATE_VERSION}${file#openwrt}"
|
||||
echo "重命名: $file → $newname"
|
||||
mv -- "$file" "$newname"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ 下载和重命名完成"
|
Loading…
Reference in New Issue
Block a user