diff options
author | typebrook <typebrook@gmail.com> | 2019-12-13 13:46:43 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-13 13:46:43 +0800 |
commit | c9a6cd4bd88add67543745af0c784ba389b599a2 (patch) | |
tree | 98b68c6ba44fe00b416b211a139359e0c490b2a1 /scripts/upload-github-release-asset.sh | |
parent | 46b38dce5448da3c5bf77b430d17d686d7777e6f (diff) |
update
Diffstat (limited to 'scripts/upload-github-release-asset.sh')
-rwxr-xr-x | scripts/upload-github-release-asset.sh | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/upload-github-release-asset.sh b/scripts/upload-github-release-asset.sh index ee2723b..e43c573 100755 --- a/scripts/upload-github-release-asset.sh +++ b/scripts/upload-github-release-asset.sh | |||
@@ -12,12 +12,13 @@ | |||
12 | # * tag | 12 | # * tag |
13 | # * filename | 13 | # * filename |
14 | # * github_api_token | 14 | # * github_api_token |
15 | # * overwrite (optional, default to be false) | ||
15 | # | 16 | # |
16 | # Script to upload a release asset using the GitHub API v3. | 17 | # Script to upload a release asset using the GitHub API v3. |
17 | # | 18 | # |
18 | # Example: | 19 | # Example: |
19 | # | 20 | # |
20 | # upload-github-release-asset.sh github_api_token=TOKEN owner=stefanbuck repo=playground tag=v0.1.0 filename=./build.zip | 21 | # upload-github-release-asset.sh github_api_token=TOKEN owner=stefanbuck repo=playground tag=v0.1.0 filename=./build.zip overwrite=true |
21 | # | 22 | # |
22 | 23 | ||
23 | # Check dependencies. | 24 | # Check dependencies. |
@@ -61,8 +62,14 @@ eval $(echo "$response" | grep -C2 "\"name\":.\+$(basename $filename)" | grep -m | |||
61 | if [ "$asset_id" = "" ]; then | 62 | if [ "$asset_id" = "" ]; then |
62 | echo "No need to overwrite asset" | 63 | echo "No need to overwrite asset" |
63 | else | 64 | else |
64 | echo "Deleting asset($asset_id)... " | 65 | if [ "$overwrite" ]; then |
65 | curl -X "DELETE" -H "Authorization: token $github_api_token" "https://api.github.com/repos/$owner/$repo/releases/assets/$asset_id" | 66 | echo "Deleting asset($asset_id)... " |
67 | curl -X "DELETE" -H "Authorization: token $github_api_token" "https://api.github.com/repos/$owner/$repo/releases/assets/$asset_id" | ||
68 | else | ||
69 | echo "File already exists on tag $tag" | ||
70 | echo "If you want to overwrite it, set overwrite=true" | ||
71 | exit 0 | ||
72 | fi | ||
66 | fi | 73 | fi |
67 | 74 | ||
68 | # Upload asset | 75 | # Upload asset |