files/OpenWrt/upload.sh
zhao 9540a78779 更新 OpenWrt/upload.sh
Signed-off-by: zhao <zhao@noreply.localhost>
2025-04-02 01:43:36 +08:00

49 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# 配置参数
REPO="oppen321/ZeroWrt-Action"
# 1. 下载GitHub Release文件
echo "➜ 下载GitHub Release文件..."
# 根据架构选择对应的tag
if [ "$model" = "x86_64" ]; then
TAG="OpenWrt-X86_64-24.10"
elif [ "$model" = "rockchip" ]; then
TAG="OpenWrt-Rockchip-24.10"
else
echo "❌ 未指定有效的model参数 (x86_64 或 rockchip)"
exit 1
fi
# 获取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 " - tag名称不正确: ${TAG}"
echo " - 仓库中没有该tag的release"
echo " - API请求被限制尝试添加GitHub token"
exit 1
fi
mkdir -p ./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/' openwrt*
echo "✅ 下载和重命名完成"