Last active
January 7, 2022 19:55
-
-
Save joshjohanning/dd01c4543c92b3567eaa2ce1d381825f to your computer and use it in GitHub Desktop.
Get package version download url for a specific package and specific version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
It's slightly less gross if you just need to the latest package version download url
{
repository(owner: "joshjohanning", name: "Wolfringo-github-packages") {
packages(first: 10, packageType: NUGET, names: "Wolfringo.Commands") {
edges {
node {
id
name
packageType
versions(first: 100) {
nodes {
id
version
files(first: 10) {
nodes {
name
url
}
}
}
}
}
}
}
}
}
Result:
{
"data": {
"repository": {
"packages": {
"edges": [
{
"node": {
"id": "MDc6UGFja2FnZTYzNjAxOA==",
"name": "Wolfringo.Commands",
"packageType": "NUGET",
"versions": {
"nodes": [
{
"id": "MDE0OlBhY2thZ2VWZXJzaW9uNzE5MjAwMA==",
"version": "1.1.2",
"files": {
"nodes": [
{
"name": "package.nupkg",
"url": "https://github-registry-files.githubusercontent.com/341640418/5e5d8280-7606-11eb-974a-d1d68831b6e1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211130%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211130T194734Z&X-Amz-Expires=300&X-Amz-Signature=4fbb0baf3d692cb706507b6f24b91705e6a7f6fc7a8c38a128b37111bff8487e&X-Amz-SignedHeaders=host&actor_id=19912012&key_id=0&repo_id=341640418&response-content-disposition=filename%3Dpackage.nupkg&response-content-type=application%2Foctet-stream"
}
]
}
}
]
}
}
}
]
}
}
}
}
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
(apologies I am a graphql noob)
this returns something like