File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,26 @@ DIR=$(dirname "$0")
66
77TAG_NAME=${1?}
88PATTERN=$( basename " ${2?} " )
9- JSON=$( fetch_json " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/tags/$TAG_NAME " " $GITHUB_TOKEN " )
9+ JSON=$( fetch_json " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/\
10+ tags/$TAG_NAME " " $GITHUB_TOKEN " )
1011RELEASE_ID=$( jq -r ' .id' " $JSON " )
1112rm " $JSON "
12- JSON=$( fetch_json " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/$RELEASE_ID /assets" " $GITHUB_TOKEN " array)
13+ JSON=$( fetch_json " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/\
14+ $RELEASE_ID /assets" " $GITHUB_TOKEN " array)
1315LEN=$( jq length " $JSON " )
1416n=-1; while n=$(( n + 1 )) ; [ " $n " -lt " $LEN " ]; do
1517 NAME=$( jq -r " .[$n ].name" " $JSON " )
16- if expr " $NAME " : " $PATTERN $" ; then
17- ID=$( jq " .[$n ].id" " $JSON " )
18- JSON2=$( mktemp)
19- STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -X DELETE " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/assets/$ID " -w ' %{http_code}' -o " $JSON2 " )
20- check_errors " $JSON2 "
21- check_status " $STATUS "
22- rm " $JSON2 "
18+ if ! expr " $NAME " : " $PATTERN $" ; then
19+ continue
2320 fi
21+ ID=$( jq " .[$n ].id" " $JSON " )
22+ JSON2=$( mktemp)
23+ STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -X DELETE \
24+ " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/assets/$ID " \
25+ -w ' %{http_code}' -o " $JSON2 " )
26+ check_errors " $JSON2 "
27+ check_status " $STATUS "
28+ rm " $JSON2 "
2429done
2530rm " $JSON "
2631
Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ FILENAME=$(basename "${2?}")
1010CONTENT_TYPE=${3?}
1111LABEL=$( echo " ${4?} " | sed ' s/ /%20/g' )
1212
13- JSON=$( fetch_json " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/tags/$TAG_NAME " " $GITHUB_TOKEN " )
13+ JSON=$( fetch_json\
14+ " https://api.github.com/repos/$GITHUB_REPOSITORY /releases/tags/$TAG_NAME " \
15+ " $GITHUB_TOKEN " )
1416UPLOAD_URL=$( jq -r .upload_url " $JSON " | sed " s/{.*}//" )
1517
1618JSON=$( mktemp)
17- STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -H " Content-Type: $CONTENT_TYPE " -X POST " $UPLOAD_URL ?name=$FILENAME &label=$LABEL " -T " $FILE " -w ' %{http_code}' -o " $JSON " )
19+ STATUS=$( curl -S -H " Authorization: token $GITHUB_TOKEN " -H\
20+ " Content-Type: $CONTENT_TYPE " -X POST " $UPLOAD_URL ?name=$FILENAME &label=$LABEL " \
21+ -T " $FILE " -w ' %{http_code}' -o " $JSON " )
1822check_errors " $JSON "
1923check_status " $STATUS "
2024rm " $JSON "
You can’t perform that action at this time.
0 commit comments