-
Notifications
You must be signed in to change notification settings - Fork 0
/
github-tagrelease
executable file
·59 lines (55 loc) · 1.64 KB
/
github-tagrelease
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
json() {
python -c "
import json,sys
try:
print(json.load(sys.stdin)$@)
except IndexError:
pass
"
}
MYDIR="$(realpath $(dirname $0))"
TEMP="`mktemp -d /tmp/ghc2rXXXXXX`"
cd $TEMP
if [ -z "$OAUTH_TOKEN" ]; then
echo "Before running this script, set OAUTH_TOKEN to a token"
echo "generated using https://github.com/settings/token"
exit 1
fi
START=""
PERPAGE=100
COUNT=0
for org in OpenMandrivaAssociation; do
while true; do
QUERY="{\"query\": \"query {organization(login:\\\"$org\\\") { id name repositories(first:$PERPAGE $START) { edges { node { id name } cursor } pageInfo { endCursor hasNextPage } } } }\""
REPOS="$(curl -H "Authorization: token $OAUTH_TOKEN" -X POST -d "$QUERY" https://api.github.com/graphql 2>/dev/null)"
if [ -z "$REPOS" ]; then
echo "$QUERY failed" >&2
break
fi
for i in $(seq 0 $((PERPAGE-1))); do
R="$(echo $REPOS |json "['data']['organization']['repositories']['edges'][$i]['node']['name']")"
[ "$R" = "distro-release" -o "$R" = "openmandriva-repos" ] && continue
if [ -z "$R" ]; then
echo "No more repositories at $QUERY $i" >&2
break
fi
COUNT=$((COUNT+1))
echo "Retagging $org/$R"
cd "$TEMP"
git clone "[email protected]:$org/$R"
if [ -d "$R" ]; then
cd "$R"
git checkout -b 6.0 origin/master
git push --force origin 6.0
cd ..
rm -rf "$R"
fi
done
[ "$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['hasNextPage']")" != "True" ] && break
START="after:\\\"$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['endCursor']")\\\""
done
done
echo "$COUNT repositories retagged."
cd "$MYDIR"
rm -rf "$TEMP"