blob: 607c5fd250229e6ae5db6bdb6318de1bef24b570 (
plain)
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
|
#!/bin/sh
base_dir=$(
dirname "$(
readlink -f "$0"
)"
)
api_url='https://api.github.com'
auth='Authorization: token '"$(
gpg -d -o - "${base_dir}/pw.gpg" 2>/dev/null
)"
owner='archlinux32'
repo='archlinux32-keyring'
tag='v20180411'
file='test.asc'
name='test.asc'
repo_url="${api_url}/repos/${owner}/${repo}"
tags_url="${repo_url}/releases/tags/${tag}"
response=$(
curl -sH "${auth}" "${repo_url}"
)
if echo "${response}" | \
grep -qF '"Bad credentials"'; then
>&2 echo "${response}"
exit 1
fi
eval $(
curl -sH "${auth}" "${tags_url}" | \
grep -m1 '"id":' | \
tr : = | \
tr -cd '[[:alnum:]]='
)
if [ -z "${id}" ]; then
>&2 printf 'Error: Failed to get release id for tag %s.\n' "${tag}"
>&2 printf '%s\n' "${response}"
exit 1
fi
upload_url="https://uploads.github.com/repos/${owner}/${repo}/releases/${id}/assets?name=${name}"
curl \
--data-binary @"${file}" \
-H "${auth}" \
-H "Content-Type: application/octet-stream" \
"${upload_url}"
|