GitHub Releases Uploading
Travis CI can automatically upload assets from your
$TRAVIS_BUILD_DIR to git tags on your GitHub repository.
Please note that deploying GitHub Releases works only for tags, not for branches.
For a minimal configuration, add the following to your
deploy: provider: releases api_key: "GITHUB OAUTH TOKEN" file: "FILE TO UPLOAD" skip_cleanup: true on: tags: true
Make sure you have
true, otherwise Travis CI will delete all the files created during the build, which will probably delete what you are trying to upload.
on: tags: true section at the end of the
.travis.yml above is required to make sure that your tags get deployed.
If you need to overwrite existing files, add
overwrite: true to the
deploy section of your
You can also use the Travis CI command line client to configure your
travis setup releases
Or, if you’re using a private repository:
travis setup releases --pro
Authenticating with an OAuth token
The recommended way to authenticate is to use a GitHub OAuth token. It must have the
repo scope to upload assets. Instead of setting it up manually, it is highly recommended to use
travis setup releases, which automatically creates and encrypts a GitHub oauth token with the correct scopes.
This results in something similar to:
deploy: provider: releases api_key: secure: YOUR_API_KEY_ENCRYPTED file: "FILE TO UPLOAD" skip_cleanup: true on: tags: true
Authentication with a Username and Password
You can also authenticate with your GitHub username and password using the
password options. This is not recommended as it allows full access to your GitHub account but is simplest to setup. It is recommended to encrypt your password using
travis encrypt "GITHUB PASSWORD" --add deploy.password. This example authenticates using a username and password.
deploy: provider: releases user: "GITHUB USERNAME" password: "GITHUB PASSWORD" file: "FILE TO UPLOAD" skip_cleanup: true on: tags: true
Deploying to GitHub Enterprise
If you wish to upload assets to a GitHub Enterprise repository, you must override the
$OCTOKIT_API_ENDPOINT environment variable with your GitHub Enterprise API endpoint:
http(s)://"GITHUB ENTERPRISE HOSTNAME"/api/v3/
You can configure this in Repository Settings or via your
env: global: - OCTOKIT_API_ENDPOINT="GITHUB ENTERPRISE API ENDPOINT"
Uploading Multiple Files
You can upload multiple files using yml array notation. This example uploads two files.
deploy: provider: releases api_key: secure: YOUR_API_KEY_ENCRYPTED file: - "FILE 1" - "FILE 2" skip_cleanup: true on: tags: true
You can also enable wildcards by setting
true. This example
includes all files in a given directory.
deploy: provider: releases api-key: "GITHUB OAUTH TOKEN" file_glob: true file: directory/* skip_cleanup: true on: tags: true
You can deploy only when certain conditions are met.
See Conditional Releases with
Running commands before or after release
Sometimes you want to run commands before or after releasing a gem. You can use the
after_deploy stages for this. These will only be triggered if Travis CI is actually pushing a release.
before_deploy: "echo 'ready?'" deploy: .. after_deploy: - ./after_deploy_1.sh - ./after_deploy_2.sh
Pushing a specific directory
local_dir: Directory to push to GitHub Releases, defaults to the current directory
.travis.yml are passed through to Octokit API, so you can use any valid Octokit option.