Skip to content

Commit 71cff50

Browse files
committed
adding new download package scripts and deprecating old ones
1 parent 4e20aa7 commit 71cff50

6 files changed

+105
-8
lines changed

gh-cli/README.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,32 @@ Gets a team
251251

252252
Get outside collaborators added to a repository
253253

254-
## get-package-download-url.sh
255-
256-
Gets a the dynamic package download URL for a given package type, name, and version.
257-
258254
## get-package-download-url-for-latest-version
259255

260256
Retrieve the download URL for the latest version of a package in GitHub Packages. See: [Documentation](https://docs.github.com/en/graphql/reference/objects#package)
261257

258+
> **Note:**
259+
> No longer works for GitHub.com and deprecated for GHES 3.7+. See [Changelog post](https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/), [GraphQL breaking changes](https://docs.github.com/en/graphql/overview/breaking-changes#changes-scheduled-for-2022-11-21-1), and [GHES 3.7 deprecations](https://docs.github.com/en/[email protected]/admin/release-notes#3.7.0-deprecations)
260+
261+
## get-package-download-url-for-specific-version-maven.sh
262+
263+
Retrieve the download URL for a specific version of an Maven package in GitHub Packages.
264+
265+
## get-package-download-url-for-specific-version-npm.sh
266+
267+
Retrieve the download URL for a specific version of an NPM package in GitHub Packages.
268+
269+
## get-package-download-url-for-specific-version-nuget.sh
270+
271+
Retrieve the download URL for a specific version of an Maven package in GitHub Packages.
272+
262273
## get-package-download-url-for-specific-version.sh
263274

264275
Retrieve the download URL for a specific version of a package in GitHub Packages. See: [Documentation](https://docs.github.com/en/graphql/reference/objects#package)
265276

277+
> **Note:**
278+
> No longer works for GitHub.com and deprecated for GHES 3.7+. See [Changelog post](https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/), [GraphQL breaking changes](https://docs.github.com/en/graphql/overview/breaking-changes#changes-scheduled-for-2022-11-21-1), and [GHES 3.7 deprecations](https://docs.github.com/en/[email protected]/admin/release-notes#3.7.0-deprecations)
279+
266280
## get-releases.sh
267281

268282
Gets a list of releases for a repository

gh-cli/get-package-download-url-for-latest-version.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22

3+
# No longer works for GitHub.com and deprecated for GHES 3.7+
4+
#
5+
# See:
6+
# - https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/
7+
# - https://docs.github.com/en/graphql/overview/breaking-changes#changes-scheduled-for-2022-11-21-1
8+
# - https://docs.github.com/en/[email protected]/admin/release-notes#3.7.0-deprecations
9+
310
# gh auth refresh -h github.com -s read:packages
411

512
# packageType (https://docs.github.com/en/graphql/reference/enums#packagetype)
6-
# - DEBIAN
713
# - DOCKER
814
# - MAVEN
915
# - NPM
1016
# - NUGET
11-
# - PYPI
1217
# - RUBYGEMS
1318

1419
gh api graphql -f packageType="NUGET" -f owner="joshjohanning-org" -f repo="Wolfringo-github-packages" -f packageName="Wolfringo.Core" -f query='
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# gh auth refresh -h github.com -s read:packages
4+
5+
if [ $# -ne "4" ]; then
6+
echo "Usage: $0 <org> <package_name> <version> <file-type>"
7+
echo "Example: ./get-package-download-url-for-specific-version-maven.sh joshjohanning-org com.sherlock.herokupoc 1.0.0-202202122241 jar"
8+
exit 1
9+
fi
10+
11+
12+
org="$1"
13+
package_name="$2"
14+
version="$3"
15+
filetype="$4"
16+
token=$(gh auth token)
17+
18+
# get everything after com.[word].*
19+
package_name_short=$(echo $package_name | sed 's/.*\.\(.*\)/\1/g')
20+
echo "artifactId: $package_name_short"
21+
22+
# convert . to /
23+
package_name_slashes=$(echo $package_name | sed 's/\./\//g')
24+
echo "groupID and artifactId converted to slashes format: $package_name_slashes"
25+
26+
# download
27+
curl -H "Authorization: token $token" -L -O https://maven.pkg.github.com/$org/download/$package_name_slashes/$version/$package_name_short-$version.$filetype
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# gh auth refresh -h github.com -s read:packages
4+
5+
if [ $# -ne "3" ]; then
6+
echo "Usage: $0 <org> <package_name> <version>"
7+
echo "Example: ./get-package-download-url-for-specific-version-npm.sh joshjohanning-org npm-package-example 0.0.3"
8+
exit 1
9+
fi
10+
11+
12+
org="$1"
13+
package_name="$2"
14+
version="$3"
15+
token=$(gh auth token)
16+
17+
# get url
18+
url=$(curl -H "Authorization: token $token" -Ls https://npm.pkg.github.com/@$org/$package_name | jq --arg version $version -r '.versions[$version].dist.tarball')
19+
20+
# check for error
21+
if [ "$url" == "null" ]; then
22+
echo "ERROR: version $version not found for package $package_name"
23+
echo "NOTE: Make sure you have the proper scopes for gh; ie run this: gh auth refresh -h github.com -s read:packages"
24+
exit 1
25+
fi
26+
27+
# download
28+
curl -H "Authorization: token $token" -L -o $package_name-$version.tgz $url
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# gh auth refresh -h github.com -s read:packages
4+
5+
if [ $# -ne "3" ]; then
6+
echo "Usage: $0 <org> <package_name> <version>"
7+
echo "Example: ./get-package-download-url-for-specific-version-nuget.sh joshjohanning-org Wolfringo.Hosting 1.1.1"
8+
exit 1
9+
fi
10+
11+
12+
org="$1"
13+
package_name="$2"
14+
version="$3"
15+
token=$(gh auth token)
16+
17+
# download
18+
curl -H "Authorization: token $token" -L -O https://nuget.pkg.github.com/$org/download/$package_name/$version/$package_name.$version.nupkg

gh-cli/get-package-download-url-for-specific-version.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22

3+
# No longer works for GitHub.com and deprecated for GHES 3.7+
4+
#
5+
# See:
6+
# - https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/
7+
# - https://docs.github.com/en/graphql/overview/breaking-changes#changes-scheduled-for-2022-11-21-1
8+
# - https://docs.github.com/en/[email protected]/admin/release-notes#3.7.0-deprecations
9+
310
# gh auth refresh -h github.com -s read:packages
411

512
# packageType (https://docs.github.com/en/graphql/reference/enums#packagetype)
6-
# - DEBIAN
713
# - DOCKER
814
# - MAVEN
915
# - NPM
1016
# - NUGET
11-
# - PYPI
1217
# - RUBYGEMS
1318

1419
gh api graphql -f packageType="NUGET" -f owner="joshjohanning-org-packages" -f repo="packages-repo1" -f packageName="NUnit3.DotNetNew.Template" -f packageVersion="1.7.0" -f query='

0 commit comments

Comments
 (0)