简体   繁体   English

如何从 API 捕获项目的最新 GitHub 版本?

[英]How do I capture the latest GitHub release of a project from the API?

I am trying to grab the download url of latest release from GitHub API page .我正在尝试从 GitHub API 页面下载最新版本的 url 。

I first need to capture all the lines which start with browser_download_url and further grab the one having linux64 in them.我首先需要捕获所有以browser_download_url开头的行,并进一步抓取其中包含linux64的行。

Target link currently which it should capture - https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz当前应该捕获的目标链接 - https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz

After some research, i tried doing the following -经过一些研究,我尝试执行以下操作 -

curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | grep "browser_download_url | grep 'linux64[.]gz' | head -n 1 | cut -d '"' -f 4

But it doesn't seem to work.但这似乎不起作用。

Also it doesn't necessarily have to be an edit of my attempt, I don't mind if awk, sed etc are used in answers此外,它不一定是我尝试的编辑,我不介意 awk、sed 等是否用于答案

Like this:像这样:

curl -s 'https://api.github.com/repos/mozilla/geckodriver/releases/latest' | 
    jq -r '.assets[].browser_download_url' |
    grep linux64

https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM