Extending upon @galeksandrp's answer, here are some issues I encountered
Note that the --data-binary
option copies the file contents first to RAM, so if you have large files say close to 2048MB i.e. the absolute limit for github releases and if the RAM isn't enough, it fails with curl: option -d: out of memory
.
The fix for that is to use -T file path
(without the @).
And also on a side note, if you want to see the upload progress, you need to pipe the output to cat
such as curl <...the whole command> | cat
So the complete command would look like this
curl -X POST \
-H "Content-Length: <file size in bytes>" \
-H "Content-Type: $(file -b --mime-type $FILE)" \ #from @galeksandrp's answer
-T "path/to/large/file.ext" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://uploads.github.com/repos/<username>/<repo>/releases/<id>/assets?name=<name> | cat
Note:
An alternate way is to use gh release upload <tag> <files>... [flags]
instead of curl. (docs)
gh
is GitHub's official command line tool.