GitHub Releases Uploading
Travis CI can automatically upload assets from your
$TRAVIS_BUILD_DIR to git tags on your GitHub repository.
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
If you are using the
branches.only property, remember that when you push a tag, the
$TRAVIS_BRANCH property contains the name of the tag. As a result, edit the
branches.only property to add the names of the tags you might push in the future. You can use a regular expression if you have formalized names. For example, if your release tags look like
v1.3.15, use the following configuration:
branches: only: - master - /^v\d+(\.\d+)+$/
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.