Skip to content

Commit 2beef60

Browse files
committed
Allow publishing new binaries on a existing release (continue an interrupted upload)
1 parent 97a6985 commit 2beef60

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/releases
12
*.deb
23
archs

publish.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/bin/bash
2-
set -e
1+
#!/bin/bash -e
32

43
# A POSIX variable
54
OPTIND=1 # Reset in case getopts has been used previously in the shell.
@@ -17,6 +16,7 @@ shift $((OPTIND-1))
1716

1817
[ "$1" = "--" ] && shift
1918

19+
rm -rf releases
2020
mkdir releases
2121
cp /usr/bin/qemu-*-static releases/
2222
cd releases/
@@ -25,6 +25,7 @@ for file in *; do
2525
cp $file.tar.gz x86_64_$file.tar.gz
2626
done
2727

28+
# create a release
2829
release_id=$(curl -sL -X POST \
2930
-H "Content-Type: application/json" \
3031
-H "Accept: application/vnd.github.v3+json" \
@@ -37,6 +38,15 @@ release_id=$(curl -sL -X POST \
3738
\"draft\": false,
3839
\"prerelease\": false
3940
}" "https://api.github.com/repos/multiarch/qemu-user-static/releases" | jq -r ".id")
41+
if [ "$release_id" = "null" ]; then
42+
# get the existing release id
43+
release_id=$(set -x; curl -sL \
44+
-H "Content-Type: application/json" \
45+
-H "Accept: application/vnd.github.v3+json" \
46+
-H "Authorization: token ${GITHUB_TOKEN}" \
47+
-H "Cache-Control: no-cache" \
48+
"https://api.github.com/repos/multiarch/qemu-user-static/releases" | jq -r --arg version "$VERSION" '.[] | select(.name == "v"+$version).id')
49+
fi
4050

4151
for file in *; do
4252
content_type=$(file --mime-type -b ${file})

0 commit comments

Comments
 (0)