GitHub Releases Uploading
Travis CI can automatically upload assets from your
$TRAVIS_BUILD_DIR to your 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
travis setup releases
Authenticating with an Oauth token
The recommend way of authentication is with 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 will automatically create a GitHub oauth token with the correct scopes and encrypts it.
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 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