2012-04-17 23:59:43 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-04-12 01:45:52 +04:00
|
|
|
die () {
|
|
|
|
echo "$*" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
test $# -ge 2 ||
|
|
|
|
die "Usage: $0 <tag-name> <path>..."
|
|
|
|
|
|
|
|
tagname="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
url=https://api.github.com/repos/msysgit/msysgit/releases
|
|
|
|
id="$(curl --netrc -s $url |
|
|
|
|
grep -B1 "\"tag_name\": \"$tagname\"" |
|
|
|
|
sed -n 's/.*"id": *\([0-9]*\).*/\1/p')"
|
|
|
|
test -n "$id" || {
|
|
|
|
out="$(curl --netrc -s -XPOST -d '{"tag_name":"'"$tagname"'"}' $url)" ||
|
|
|
|
die "Error creating release: $out"
|
|
|
|
id="$(echo "$out" |
|
|
|
|
sed -n 's/.*"id": *\([0-9]*\).*/\1/p')"
|
|
|
|
test -n "$id" ||
|
|
|
|
die "Could not create release for tag $tagname"
|
|
|
|
}
|
2012-04-17 23:59:43 +04:00
|
|
|
|
2014-04-12 01:45:52 +04:00
|
|
|
url=https://uploads.${url#https://api.}
|
2012-04-17 23:59:43 +04:00
|
|
|
|
2014-04-12 01:45:52 +04:00
|
|
|
for path
|
2012-04-17 23:59:43 +04:00
|
|
|
do
|
2014-04-12 01:45:52 +04:00
|
|
|
case "$path" in
|
|
|
|
*.exe)
|
|
|
|
contenttype=application/executable
|
2012-04-17 23:59:43 +04:00
|
|
|
;;
|
2014-04-12 01:45:52 +04:00
|
|
|
*.7z)
|
|
|
|
contenttype=application/zip
|
2012-04-17 23:59:43 +04:00
|
|
|
;;
|
|
|
|
*)
|
2014-04-12 01:45:52 +04:00
|
|
|
die "Unknown file type: $path"
|
|
|
|
;;
|
2012-04-17 23:59:43 +04:00
|
|
|
esac
|
2014-04-12 01:45:52 +04:00
|
|
|
basename="$(basename "$path")"
|
|
|
|
curl -i --netrc -XPOST -H "Content-Type: $contenttype" \
|
|
|
|
--data-binary @"$path" "$url/$id/assets?name=$basename"
|
2012-04-17 23:59:43 +04:00
|
|
|
done
|