嘟嘟社区

wget怎么下载GitHub的latest releases,而不是对应的版本号?想....


本帖最后由 腾讯云6折购 于 2022-6-28 23:09 编辑

想每次都下载最新版

https://docs.github.com/cn/repositories/releasing-projects-on-github/linking-to-releases

卵而发现releases文件中包含版本号。。。
去找对应的下就行
如果是生产用途,可以搞个php中转一下
  
参考 https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest
有些包名就有版本号,所以这种只适用于包名不含版本号的情况。
  1. #!/bin/bash
  2. VER="$(curl -s https://api.github.com/repos/caddyserver/caddy/releases/latest | sed ‘y/,/n/’ | grep tag_name | awk -F ‘"’ ‘{print $4}’)"
  3. CUR_VER="$($HOME/caddy/caddy version | cut -d " " -f1)"
  4. if [[ "$VER" == "$CUR_VER" ]] ; then
  5.   echo "Lastest version $VER is already installed,exiting…"
  6.   exit
  7. fi
  8. ARCH=$(uname -m)
  9. VDIS="amd64"
  10. if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then
  11.   VDIS="386"
  12. elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then
  13.   VDIS="arm64"
  14. fi
  15. mkdir -p /tmp/caddy
  16. echo "Installing Caddy ${VER} on ${ARCH}"
  17. DOWNLOAD_LINK="https://github.com/caddyserver/caddy/releases/download/${VER}/caddy_${VER##*v}_linux_${VDIS}.tar.gz"
  18. echo "Downloading ${DOWNLOAD_LINK} directly."
  19. curl -L -H "Cache-Control: no-cache" -o "/tmp/caddy/caddy.tar.gz" ${DOWNLOAD_LINK}
  20. echo "Extracting Caddy package to /tmp/caddy/."
  21. tar zxvf "/tmp/caddy/caddy.tar.gz" -C "/tmp/caddy/"
  22. rm $HOME/caddy/caddy
  23. cp "/tmp/caddy/caddy" "$HOME/caddy/caddy"

复制代码