mirror of
https://github.com/LibreELEC/LibreELEC.tv
synced 2025-09-24 19:46:01 +07:00
update scripts: rework tag fetching with GitHub API
Use GitHub GraphQL API to sort fetched tags by date instead by version number.
This commit is contained in:
@@ -84,17 +84,27 @@ resolve_tag_in_branch() {
|
||||
resolve_tag_on_gh() {
|
||||
local tag
|
||||
|
||||
tag=$(curl -s -L -H "Authorization: token ${GITHUB_API_TOKEN}" \
|
||||
"${1/*github.com/https:\/\/api.github.com\/repos}/releases" | \
|
||||
jq -r '[.[] | select(.target_commitish == "'$2'")][0].tag_name | select (.!=null)')
|
||||
local QUERY=$(tr '\n' ' ' <<EOF
|
||||
{
|
||||
repository(owner: \\"${1}\\", name: \\"${2}\\") {
|
||||
refs(refPrefix: \\"refs/tags/\\", first: 100, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
|
||||
edges {
|
||||
node {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ -z "$tag" ] ; then
|
||||
tag=$(curl -s -L -H "Authorization: token ${GITHUB_API_TOKEN}" \
|
||||
"${1/*github.com/https:\/\/api.github.com\/repos}/tags" | \
|
||||
jq -r '[.[] | select(.name | contains("'$2'"))][0].name | select (.!=null)')
|
||||
fi
|
||||
tag=$(curl -s -L -H 'Content-Type: application/json' \
|
||||
-H "Authorization: bearer ${GITHUB_API_TOKEN}" \
|
||||
-X POST -d "{ \"query\": \"${QUERY}\" }" https://api.github.com/graphql | \
|
||||
jq -r '[.data.repository.refs.edges[] | select(.node.name | contains("'${3}'"))][0].node.name | select (.!=null)')
|
||||
|
||||
echo "$tag"
|
||||
echo "${tag}"
|
||||
}
|
||||
|
||||
check_package_excluded() {
|
||||
|
||||
Reference in New Issue
Block a user