mirror of
https://github.com/actions/runner-images.git
synced 2026-01-08 03:07:32 +08:00
[macOS] Implement helper to get GitHub package download URL (#4923)
This commit is contained in:
committed by
GitHub
parent
5217af8068
commit
f747f0983b
@@ -171,3 +171,26 @@ configure_user_tccdb () {
|
||||
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
|
||||
sqlite3 "$dbPath" "$sqlQuery"
|
||||
}
|
||||
|
||||
get_github_package_download_url() {
|
||||
local REPO_OWNER=$1
|
||||
local REPO_NAME=$2
|
||||
local FILTER=$3
|
||||
local VERSION=$4
|
||||
local API_PAT=$5
|
||||
local SEARCH_IN_COUNT="100"
|
||||
|
||||
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
|
||||
|
||||
json=$(curl "${authString[@]}" -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases?per_page=${SEARCH_IN_COUNT}")
|
||||
|
||||
if [[ "$VERSION" == "latest" ]]; then
|
||||
tagName=$(echo $json | jq -r '.[] | select(.prerelease==false).tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]" | tail -1)
|
||||
else
|
||||
tagName=$(echo $json | jq -r '.[] | select(.prerelease==false).tag_name' | sort --unique --version-sort | egrep -v ".*-[a-z]" | egrep "\w*${VERSION}" | tail -1)
|
||||
fi
|
||||
|
||||
downloadUrl=$(echo $json | jq -r ".[] | select(.tag_name==\"${tagName}\").assets[].browser_download_url | select(${FILTER})" | head -n 1)
|
||||
|
||||
echo $downloadUrl
|
||||
}
|
||||
Reference in New Issue
Block a user