diff options
-rw-r--r-- | alias | 1 | ||||
-rwxr-xr-x | scripts/upload-github-release-asset.sh | 13 |
2 files changed, 11 insertions, 3 deletions
@@ -111,6 +111,7 @@ upload-tig() { | |||
111 | repo=tig \ | 111 | repo=tig \ |
112 | tag=LATEST \ | 112 | tag=LATEST \ |
113 | filename=$(which tig) | 113 | filename=$(which tig) |
114 | overwrite=false | ||
114 | } | 115 | } |
115 | 116 | ||
116 | # Android | 117 | # Android |
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 |