Create Release and Upload Build Artifact on GitHub from the Command Line

I was looking for a way to create new releases and upload binaries on GitHub from the command line.

I stumbled upon github-release, a small CLI tool written in Go that call the GitHub Release API. Perfect for the job!

First, you need to generate a personal access token on GitHub with public_repo (and/or repo) scope.

Then, you need to build or download a release of github-release (uploaded with github-release for the win).

Start by creating a tag, and push it to GitHub:

$ git tag v0.1.0
$ git push --tags

Now you can create the release and upload build artifacts without leaving the command line:

# Set your GitHub token
$ export GITHUB_TOKEN=...
# Create the release
$ github-release release --user readratio --repo socialactivity --tag v0.1.0 --name "v0.1.0" --description "v0.1.0"
# Upload the binary
$ github-release upload --user readratio --repo socialactivity --tag v0.1.0 --name "socialactivity-linux-amd64" --file socialactivity

Finally, I'll share with you the the Makefile I use to upload the minified version of socialactivity.js:

V=$(shell git describe --tags)

        github-release release --user readratio --repo socialactivity.js --tag $(V) --name "$(V)" --description "$(V)"
        github-release upload --user readratio --repo socialactivity.js --tag $(V) --name "socialactivity.min.js" --file embed.min.js

Your feedback

Please share your feedback or any tip you might have!

You should follow me on Twitter

Share this article

Tip with Bitcoin

Tip me with Bitcoin and vote for this post!


Leave a comment

© Thomas Sileo. Powered by Pelican and hosted by DigitalOcean.