Skip to content

Commit

Permalink
fix release to github script
Browse files Browse the repository at this point in the history
  • Loading branch information
TurBoss committed May 27, 2021
1 parent feae953 commit b5b9311
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions .scripts/publish_github_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

REPO="$1"
TAG="$2"
AUTH_TOKEN="$3"
AUTH_TOKEN="$(<'/home/buildbot/.github_token')"

PRERELEASE=false
# RELEASEFILES=(debs/python-probe_basic_*.deb dist/probe_basic-*.tar.gz)
Expand All @@ -27,7 +27,8 @@ declare -a COMMIT_TYPES=(
"REV:Reverted commits"
)

LAST_RELEASE=$( git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1` )
# shellcheck disable=SC2046
LAST_RELEASE=$( git describe --abbrev=0 --tags "$(git rev-list --tags --skip=1 --max-count=1)" )

CREATE_CHANGELOG() {

Expand Down Expand Up @@ -138,16 +139,16 @@ JSON=$(cat <<EOF
}
EOF
)
RESULT=`curl -s -w "\n%{http_code}\n" \
RESULT=$(curl -s -w "\n%{http_code}\n" \
-H "Authorization: token $AUTH_TOKEN" \
-d "$JSON" \
"https://api.github.com/repos/$REPO/releases"`
if [ "`echo "$RESULT" | tail -1`" != "201" ]; then
"https://api.github.com/repos/$REPO/releases")
if [ "$(echo "$RESULT" | tail -1)" != "201" ]; then
echo FAILED
echo "$RESULT"
exit 1
fi
RELEASEID=`echo "$RESULT" | sed -ne 's/^ "id": \(.*\),$/\1/p'`
RELEASEID=$(echo "$RESULT" | sed -ne 's/^ "id": \(.*\),$/\1/p')
if [[ -z "$RELEASEID" ]]; then
echo FAILED
echo "$RESULT"
Expand All @@ -160,16 +161,17 @@ for FILE in "${RELEASEFILES[@]}"; do
echo "Warning: $FILE is not a file"
continue
fi
FILESIZE=`stat -c '%s' "$FILE"`
FILENAME=`basename $FILE`
FILESIZE=$(stat -c '%s' "$FILE")
# shellcheck disable=SC2006
FILENAME=`basename "$FILE"`
echo -n "Uploading $FILENAME... "
RESULT=`curl -s -w "\n%{http_code}\n" \
RESULT=$(curl -s -w "\n%{http_code}\n" \
-H "Authorization: token $AUTH_TOKEN" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary "@$FILE" \
"https://uploads.github.com/repos/$REPO/releases/$RELEASEID/assets?name=$FILENAME&size=$FILESIZE"`
if [ "`echo "$RESULT" | tail -1`" != "201" ]; then
"https://uploads.github.com/repos/$REPO/releases/$RELEASEID/assets?name=$FILENAME&size=$FILESIZE")
if [ "$(echo "$RESULT" | tail -1)" != "201" ]; then
echo FAILED
echo "$RESULT"
exit 1
Expand All @@ -184,12 +186,12 @@ JSON=$(cat <<EOF
}
EOF
)
RESULT=`curl -s -w "\n%{http_code}\n" \
RESULT=$(curl -s -w "\n%{http_code}\n" \
-X PATCH \
-H "Authorization: token $AUTH_TOKEN" \
-d "$JSON" \
"https://api.github.com/repos/$REPO/releases/$RELEASEID"`
if [ "`echo "$RESULT" | tail -1`" = "200" ]; then
"https://api.github.com/repos/$REPO/releases/$RELEASEID")
if [ "$(echo "$RESULT" | tail -1)" = "200" ]; then
echo DONE
else
echo FAILED
Expand Down

0 comments on commit b5b9311

Please sign in to comment.