Skip to content

Instantly share code, notes, and snippets.

@phanirithvij2000
Created October 31, 2021 17:31
Show Gist options
  • Save phanirithvij2000/a94e19f193392d92df14e8a1ec470f2d to your computer and use it in GitHub Desktop.
Save phanirithvij2000/a94e19f193392d92df14e8a1ec470f2d to your computer and use it in GitHub Desktop.
Upload file to existing github release
# https://stackoverflow.com/questions/9973056/curl-how-to-display-progress-information-while-uploading#comment104234143_41860083
# https://stackoverflow.com/a/40216228/8608146
# https://stackoverflow.com/a/69788901/8608146
# https://unix.stackexchange.com/a/185039/312058
filepath=$1
filename=$(basename $filepath)
username=$2
reponame=$3
relid=$4
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Length: $(stat -f%z $filepath)" \
-H "Content-Type: $(file -b --mime-type $filepath)" \
-T "$filepath" \
-H "Authorization: token $GITHUB_TOKEN" \
https://uploads.github.com/repos/$username/$reponame/releases/$relid/assets?name=$filename | cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment