A command-line tool for managing release assets on a GitHub repository.
npm install -g github-release-cli
Run github-release
with -h
or --help
options:
Usage: github-release <command> [<args>]
Options:
-h, --help output usage information
-V, --version output the version number
-T, --token <token> OAuth2 token
-o, --owner <owner> owner
-r, --repo <repo> repo
-t, --tag <tag> tag
-ta, --target <target> target_commitish
-n, --name <name> name
-b, --body <body> body
-d, --draft draft
-p, --prerelease prerelease
github-release upload \
--owner cheton \
--repo github-release-cli \
--tag "v0.1.0" \
--name "v0.1.0" \
--body "This release contains bug fixes and imporvements, including:\n..." \
archive.zip index.html app.min.css app.min.js
github-release upload \
--owner cheton \
--repo github-release-cli \
--tag "v0.1.0" \
--name "v0.1.0" \
--body "This is a prerelease" \
--prerelease
github-release upload \
--owner cheton \
--repo github-release-cli \
--tag "v0.1.0" \
--name "v0.1.0" \
--body "This is a published release" \
--prerelease=false
You can use glob expressions to match files:
github-release delete \
--owner cheton \
--repo github-release-cli \
--tag "v0.1.0" \
--name "v0.1.0" \
archive.zip index.html "app.*"
https://github.com/cncjs/cncjs-pendant-tinyweb/blob/master/.travis.yml
First you will need to get an OAuth Token from GitHub using your own username and "note":
curl \
-u 'username' \
-d '{"scopes":["repo"], "note":"Publish to GitHub Releases"}' \
https://api.github.com/authorizations
For users with two-factor authentication enabled, you must send the user's authentication code (i.e., one-time password) in the X-GitHub-OTP
header:
curl \
-u 'username' \
-H 'X-GitHub-OTP: 000000' \
-d '{"scopes":["repo"], "note":"Publish to GitHub Releases"}' \
https://api.github.com/authorizations
For reducing security risks, you can store your OAuth token in an environment variable.
Export the token using the one you got from above:
export GITHUB_TOKEN=your_token
Now you're ready to upload assets to a GitHub repository from a CI server. For example:
COMMIT_LOG=`git log -1 --format='%ci %H %s'`
github-release upload \
--owner=cheton \
--repo=github-release-cli \
--tag="latest" \
--name="${TRAVIS_BRANCH}" \
--body="${COMMIT_LOG}" \
"releases/myapp-0.1.0-win-x32.exe" \
"releases/myapp-0.1.0-win-x64.exe"
If you're using Travis CI, you may want to encrypt environment variables:
travis encrypt GITHUB_TOKEN=your_token
Learn how to define encrypted variables in .travis.yml:
https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml
MIT