travis-cargo,如何正确使用 GH_TOKEN
travis-cargo, how to properly use the GH_TOKEN
看github example的时候一头雾水,最后一行具体是:
language: rust
# necessary for `travis-cargo coveralls --no-sudo`
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
# run builds for all the trains (and more)
rust:
- nightly
- beta
# check it compiles on the latest stable compiler
- stable
# and the first stable one (this should be bumped as the minimum
# Rust version required changes)
- 1.0.0
# load travis-cargo
before_script:
- |
pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH
# the main build
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo bench &&
travis-cargo --only stable doc
after_success:
# upload the documentation from the build with stable (automatically only actually
# runs on the master branch, not individual PRs)
- travis-cargo --only stable doc-upload
# measure code coverage and upload to coveralls.io
- travis-cargo coveralls --no-sudo
env:
global:
# override the default `--features unstable` used for the nightly branch (optional)
- TRAVIS_CARGO_NIGHTLY_FEATURE=nightly
# encrypted github token for doc upload (see `GH_TOKEN` link above)
- secure: "..."
所以我知道我需要生成一个令牌,并且我已经生成了一个令牌,但是我如何真正告诉 travis-cargo 使用 这个?我尝试通过自述文件 link 编辑的 this link,但我不知道如何将其具体应用于 travis-cargo。
在 secure:
关键字之后,我应该用什么来代替 "..."
?显然不是令牌,因为那不是很安全,那又怎样?
我不确定为什么关于 Travis 的各种指南建议使用 Ruby gem 和手动加密的一些神秘的东西。我发现 Travis 内置环境变量功能运行良好,不需要更改 Travis 清单。
基本上,您需要转到 Travis 上的项目设置,添加 GH_TOKEN
环境变量并确保 "Display value in build log" 保持关闭状态:
(下行是添加变量的方式,上行是添加后的样子)
然后,在构建时,Travis 会自动将此变量添加到环境设置中,其值将从 build output:
中逐出
$ git clone --depth=50 --branch=master git://github.com/netvl/immeta.git netvl/immeta
$ cd netvl/immeta
$ git checkout -qf 9aba89e5466627e190f27439c2240282bf2a9029
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
If you require sudo, add 'sudo: required' to your .travis.yml
See http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.
Setting environment variables from repository settings
$ export GH_TOKEN=[secure]
Setting environment variables from .travis.yml
$ export TRAVIS_CARGO_NIGHTLY_FEATURE=""
我认为这种方式比在清单中添加各种加密令牌要好得多。
看github example的时候一头雾水,最后一行具体是:
language: rust
# necessary for `travis-cargo coveralls --no-sudo`
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
# run builds for all the trains (and more)
rust:
- nightly
- beta
# check it compiles on the latest stable compiler
- stable
# and the first stable one (this should be bumped as the minimum
# Rust version required changes)
- 1.0.0
# load travis-cargo
before_script:
- |
pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH
# the main build
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo bench &&
travis-cargo --only stable doc
after_success:
# upload the documentation from the build with stable (automatically only actually
# runs on the master branch, not individual PRs)
- travis-cargo --only stable doc-upload
# measure code coverage and upload to coveralls.io
- travis-cargo coveralls --no-sudo
env:
global:
# override the default `--features unstable` used for the nightly branch (optional)
- TRAVIS_CARGO_NIGHTLY_FEATURE=nightly
# encrypted github token for doc upload (see `GH_TOKEN` link above)
- secure: "..."
所以我知道我需要生成一个令牌,并且我已经生成了一个令牌,但是我如何真正告诉 travis-cargo 使用 这个?我尝试通过自述文件 link 编辑的 this link,但我不知道如何将其具体应用于 travis-cargo。
在 secure:
关键字之后,我应该用什么来代替 "..."
?显然不是令牌,因为那不是很安全,那又怎样?
我不确定为什么关于 Travis 的各种指南建议使用 Ruby gem 和手动加密的一些神秘的东西。我发现 Travis 内置环境变量功能运行良好,不需要更改 Travis 清单。
基本上,您需要转到 Travis 上的项目设置,添加 GH_TOKEN
环境变量并确保 "Display value in build log" 保持关闭状态:
(下行是添加变量的方式,上行是添加后的样子)
然后,在构建时,Travis 会自动将此变量添加到环境设置中,其值将从 build output:
中逐出$ git clone --depth=50 --branch=master git://github.com/netvl/immeta.git netvl/immeta
$ cd netvl/immeta
$ git checkout -qf 9aba89e5466627e190f27439c2240282bf2a9029
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
If you require sudo, add 'sudo: required' to your .travis.yml
See http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.
Setting environment variables from repository settings
$ export GH_TOKEN=[secure]
Setting environment variables from .travis.yml
$ export TRAVIS_CARGO_NIGHTLY_FEATURE=""
我认为这种方式比在清单中添加各种加密令牌要好得多。