move logic into script and out of .travis.yml