全球主机交流论坛
标题:
分享一个奇**技巧,获取github最新的releases
[打印本页]
作者:
鱼板面
时间:
2018-3-13 15:54
标题:
分享一个奇**技巧,获取github最新的releases
早上想写个Shell Script,但是包版本经常更新,我这个人又懒不想经常改动,怎么办呢
想起来github是有开放api的,这就好办了对吧,随便找找,顺利找到了api。
然后开写吧,shell解析json这个东西 真的很麻烦,写了半天正则,还是算了,不然正则比脚本还长。
然后谷歌一下,找到了jq这个东西,惊为天人,顺利把脚本缩减大半,这里也分享一下。
写点啥好呢,这里安装libsodium,相信你们懂的。
wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
chmod +x ./jq
mv jq /usr/bin
wget $(curl -s https://api.github.com/repos/jedisct1/libsodium/releases/latest | jq -r '.assets[0].browser_download_url')
#解释一下这里,用curl访问github api,获取到最新的包地址,然后用jq解析json数据
#https://developer.github.com/v3/repos/releases/
#https://stedolan.github.io/jq/
tar xf libsodium-*.tar.gz && cd libsodium-*
./configure && make -j2 && make install
ldconfig
复制代码
作者:
嫂子抱紧我
时间:
2018-3-13 16:10
https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
作者:
鱼板面
时间:
2018-3-13 16:26
嫂子抱紧我 发表于 2018-3-13 16:10
https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
大佬 牛逼 666
作者:
32MB.CN
时间:
2018-3-13 16:35
算啥奇扌支**巧,从自用脚本里摘录给你
get_latest_release() {
curl -s "https://github.com/$1/releases/latest" | perl -e 'while($_=<>){ /\/tag\/(.*)">redirected/; print $1;}
}
# Usage
# $ get_latest_release "jpillora/cloud-torrent"
# 0.8.24
复制代码
作者:
dabiantai
时间:
2018-3-14 09:13
要啥api
curl -s https://github.com/jpillora/cloud-torrent/releases| grep -oP "/releases/tag/[^\"^']+"| grep -oP "[^/^\"^']+"| head -n3|tail -n1
欢迎光临 全球主机交流论坛 (https://sunk.eu.org/)
Powered by Discuz! X3.4