-
Notifications
You must be signed in to change notification settings - Fork 369
/
checkpackages.sh
executable file
·46 lines (39 loc) · 1.36 KB
/
checkpackages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Script to report each tag in git that doesn't have a corresponding
# package on nuget.org. There are a few reasons for this:
# - The Kokoro release build wasn't triggered
# - The Kokoro release build failed
# - The package has been deleted
# - The tag is an ancient one that doesn't represent a package
set -e
# Make sure we have all the tags locally.
git fetch --tags -f -q upstream main
FAILURES=0
# Order by "most recent first" as those are the tags we're
# most likely to care about.
TAGS=$(git tag --sort=-creatordate)
echo "Checking $(echo $TAGS | wc -w) tags"
for tag in $TAGS
do
# Show progress - and also make the script easier to kill
# (git bash appears not to notice ^-C until there's output.)
echo -n "."
PACKAGE=$(echo $tag | cut --delimiter=- --fields=1)
VERSION=$(echo $tag | cut --delimiter=- --fields=2-)
# Fetch the status code via a HEAD request, using the lower-cased version
# of the package name.
STATUS=$(curl -I https://globalcdn.nuget.org/packages/${PACKAGE,,}.$VERSION.nupkg \
2>/dev/null \
| head -n 1 | cut -d$' ' -f2)
if [[ $STATUS != "200" ]]
then
# Start on a new line...
echo ""
# Show the date and tag name that doesn't have a matching package
echo "$(git log -1 --format=%aI $tag): $tag"
FAILURES=$((FAILURES+1))
fi
done
# Start on a new line...
echo ""
echo "Failures: $FAILURES"