File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 55TAG_NAME=${1?}
66PATTERN=${2?}
77JSON=$( fetch_json https://api.github.com/repos/$GITHUB_REPOSITORY /releases/tags/$TAG_NAME $GITHUB_TOKEN )
8- RELEASE_ID=$( echo " $JSON " | jq -r ' .id' )
8+ RELEASE_ID=$( printf ' %s ' " $JSON " | jq -r ' .id' )
99JSON=$( fetch_json https://api.github.com/repos/$GITHUB_REPOSITORY /releases/$RELEASE_ID /assets $GITHUB_TOKEN array)
10- LEN=$( echo " $JSON " | jq length)
10+ LEN=$( printf ' %s ' " $JSON " | jq length)
1111for n in ` seq 0 $(( $LEN - 1 )) ` ; do
12- NAME=$( echo " $JSON " | jq -r ' .[' $n ' ].name' )
12+ NAME=$( printf ' %s ' " $JSON " | jq -r ' .[' $n ' ].name' )
1313 if expr " $NAME " : " $PATTERN $" ; then
14- ID=$( echo " $JSON " | jq ' .[' $n ' ].id' )
14+ ID=$( printf ' %s ' " $JSON " | jq ' .[' $n ' ].id' )
1515 TMPNAME=$( mktemp)
1616 STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -X DELETE " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/assets/$ID " -w %{http_code} -o $TMPNAME )
1717 JSON=$( cat $TMPNAME )
Original file line number Diff line number Diff line change 11check_errors () {
2- printf ' %s' " $1 " | busybox nc x0.at 9999
32 TYPE=$( printf ' %s' " $1 " | jq -r type)
43 if [ " $TYPE " != object ]; then
54 return
65 fi
7- ERRORS=$( echo " $1 " | jq -r ' .errors' )
6+ ERRORS=$( printf ' %s ' " $1 " | jq -r ' .errors' )
87 if [ " $ERRORS " != null ]; then
98 echo $ERRORS >&2
109 exit 1
1110 fi
1211}
1312
1413check_type () {
15- TYPE=$( echo " $1 " | jq -r type)
14+ TYPE=$( printf ' %s ' " $1 " | jq -r type)
1615 if [ " $TYPE " != " $2 " ]; then
1716 echo " Wrong JSON type - expected $2 , got $TYPE " >&2
18- echo " JSON: $JSON " >&2
17+ printf ' %s ' " JSON: $JSON " >&2
1918 exit 1
2019 fi
2120}
@@ -31,13 +30,13 @@ fetch_json() {
3130 rm $TMPNAM
3231 if [ $STATUS -ne 200 ]; then
3332 echo " HTTP error code $STATUS " >&2
34- echo " JSON: $JSON " >&2
33+ printf ' %s ' " JSON: $JSON " >&2
3534 fi
3635 check_errors " $JSON "
3736 if [ -n ${3-" " } ]; then
3837 check_type " $JSON " $3
3938 fi
40- echo " $JSON "
39+ printf ' %s ' " $JSON "
4140}
4241
4342# # @brief Checks HTTP error code for success
@@ -47,7 +46,7 @@ check_status() {
4746 if [ $1 -lt 200 -o $1 -ge 300 ]; then
4847 echo " Wrong response status $STATUS !" >&2
4948 if [ -n ${2-" " } ]; then
50- echo " JSON: $JSON " >&2
49+ printf ' %s ' " JSON: $JSON " >&2
5150 fi
5251 exit 1
5352 fi
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ CONTENT_TYPE=${3?}
88LABEL=$( echo " ${4?} " | sed ' s/ /%20/g' )
99
1010JSON=$( fetch_json https://api.github.com/repos/$GITHUB_REPOSITORY /releases/tags/$TAG_NAME $GITHUB_TOKEN )
11- UPLOAD_URL=$( echo " $JSON " | jq -r .upload_url | sed " s/{.*}//" )
11+ UPLOAD_URL=$( printf ' %s ' " $JSON " | jq -r .upload_url | sed " s/{.*}//" )
1212
1313TMPNAME=$( mktemp)
1414STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -H " Content-Type: $CONTENT_TYPE " -X POST " $UPLOAD_URL ?name=$FILE &label=$LABEL " -T $FILE -w %{http_code} -o $TMPNAME )
You can’t perform that action at this time.
0 commit comments