Skip to content

Instantly share code, notes, and snippets.

@joshjohanning
Last active January 7, 2022 19:55
Show Gist options
  • Save joshjohanning/dd01c4543c92b3567eaa2ce1d381825f to your computer and use it in GitHub Desktop.
Save joshjohanning/dd01c4543c92b3567eaa2ce1d381825f to your computer and use it in GitHub Desktop.
Get package version download url for a specific package and specific version
{
repository(owner: "joshjohanning", name: "Wolfringo-github-packages") {
packages(first: 10, packageType: NUGET, names: "Wolfringo.Commands") {
edges {
node {
id
name
packageType
version(version: "1.1.2") {
id
version
files(first: 10) {
nodes {
name
updatedAt
size
url
}
}
}
}
}
}
}
}
@joshjohanning
Copy link
Author

joshjohanning commented Jan 7, 2022

Example of using curl command to get the latest download url(s):

curl 'https://api.github.com/graphql' \
  -s \
  -X POST \
  -H 'content-type: application/json' \
  -H "Authorization: Bearer xxx" \
  --data '{"query":"{\n  repository(owner: \"joshjohanning-org\", name: \"Wolfringo-github-packages\") {\n    packages(first: 10, packageType: NUGET, names: \"Wolfringo.Commands\") {\n      edges {\n        node {\n          id\n          name\n          packageType\n          versions(first: 100) {\n            nodes {\n              id\n              version\n              files(first: 10) {\n                nodes {\n                  name\n                  url\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}","variables":{}}' \
  | jq -r '.data.repository.packages.edges[].node.versions.nodes[].files.nodes[].url'
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment