于是这两天撸mod和插件的.travis.yml的时候还是整出了不少东西的,记录一下什么的。
C++: 测试Clang3.8 & GCC 6 的 Coveralls 数据
这个是当年折腾数据结构时写的CI了,因为travis的Ubuntu环境目前还是古代的12.04 precise,所以很多东西要么走PPA要么直接下
这里我用的是两个镜像,分别测Clang与GCC。由于两个编译器的目标gconv版本不同所以还需要判断一下.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
sudo: true language: generic matrix: include: - os: linux env: COMPILER_NAME=gcc CXX=g++-6 CC=gcc-6 USEFOLDEXP=false addons: apt: packages: - g++-6 - lib32stdc++6 sources: &sources - llvm-toolchain-precise-3.8 - ubuntu-toolchain-r-test - os: linux env: COMPILER_NAME=gcc CXX=g++-6 CC=gcc-6 USEFOLDEXP=true addons: apt: packages: - g++-6 - lib32stdc++6 sources: *sources - os: linux env: COMPILER_NAME=clang CXX=clang++-3.8 CC=clang-3.8 USEFOLDEXP=false addons: apt: packages: - g++-6 - clang-3.8 - lib32stdc++6 sources: *sources install: - if [[ "$COMPILER_NAME" == gcc ]] ; then sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-6 90; fi script: - mkdir -p $HOME/.local - curl -L http://www.cmake.org/files/v3.6/cmake-3.6.2-Linux-i386.tar.gz | tar -xz -C $HOME/.local --strip-components=1 - export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH - export COVERALLS_SERVICE_NAME=travis-ci - export COVERALLS_REPO_TOKEN=xCegPB5lX9j1FkHCALWoL7Wcc4VQrEno1 - mkdir build && cd build - cmake -D COVERALLS=ON -D COVERALLS_UP=ON -D USE_FOLDEXP=$USEFOLDEXP -D CMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=$CC -D CMAKE_CXX_COMPILER=$CXX .. - make - make coveralls |
Java Minecraft Forge mod:repo无关的.travis.yml & 自动更新update.json
其实主要部分还是给了gradle来做= =
要做到.travis.yml和gradle里不带repo信息的话,善于利用环境变量吧。
有一个遗憾是 travis-ci/dpl issues#613 ,暂时没法自动设定是否为prerelease^
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
language: java jdk: - oraclejdk8 before_deploy: - git config --global user.name "Travis CI" - export GIT_ORIGIN_URL=`git config --get remote.origin.url` - export GIT_LAST_MESSAGE=`git log -1 --oneline --pretty=%B` - git config credential.helper "store --file=.git/credentials" - echo "https://$GITHUB_KEY:@github.com" > .git/credentials - ./gradlew updateForgeJson - export GIT_TAG=TooltipFilter-$TRAVIS_BRANCH-v0.1.0.${TRAVIS_BUILD_NUMBER} - git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER" - git push -q --all --follow-tags > /dev/null 2>&1 - if [[ $GIT_LAST_MESSAGE =~ ^\[recommended\] ]]; then export GITHUB_DEPLOY_PRERELEASE=false; else export GITHUB_DEPLOY_PRERELEASE=true; fi - echo $GITHUB_DEPLOY_PRERELEASE - echo $GIT_LAST_MESSAGE deploy: provider: releases api_key: ${GITHUB_KEY} file: - build/libs/TooltipFilter-1.11.2-0.1.0.${TRAVIS_BUILD_NUMBER}.jar on: tags: false all_branches: true skip_cleanup: true prerelease: true branches: except: - "/^TooltipFilter.*-v[0-9]/" - "/^update/" before_install: - chmod +x gradlew install: ./gradlew setupCIWorkspace script: ./gradlew build before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock cache: directories: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
task updateForgeJson { doLast { def page = "https://github.com/Librazy/TooltipFilter/releases" if (System.getenv("FORGE_RELEASE_HOMEPAGE") != null) { page = System.getenv("FORGE_RELEASE_HOMEPAGE") } else if(System.getenv("GIT_ORIGIN_URL") != null) { page = System.getenv("GIT_ORIGIN_URL").replace(".git", "") + "/Releases" } exec { executable = 'git' args = [ 'remote', 'set-branches', '--add', 'origin', 'update' ] } exec { executable = 'git' args = [ 'fetch', '--all' ] } exec { executable = 'git' args = [ 'checkout', 'update' ] } def updateFile = new File('update.json') def json if (updateFile.exists()) { json = new JsonSlurper().parseText(updateFile.getText()) } else { def builder = new JsonBuilder() json = builder( homepage: page, promos: new HashMap<>() ) } exec { executable = 'git' args = [ 'checkout', project.minecraft.version] } def outStream = new ByteArrayOutputStream() exec { executable = 'git' args = [ 'log', '-n', '1', "--format='%B'"] standardOutput = outStream } def fullLog = outStream.toString().replaceAll("^\\s*'\\s*|\\s*'\\s*\$", "").replaceAll("[\\r\\n]+", "\n") json['homepage'] = page json['promos'][project.minecraft.version + '-latest'] = project.version if(fullLog.startsWith("[recommended]")){ json['promos'][project.minecraft.version + '-recommended'] = project.version } exec { executable = 'git' args = [ 'checkout', 'update'] } def writeFile = new File('update.json') if (!json.containsKey(project.minecraft.version)) json.put(project.minecraft.version, new HashMap<>()) def version = json[project.minecraft.version] version.put(project.version, fullLog) writeFile.write JsonOutput.prettyPrint(JsonOutput.toJson(json)) exec { executable = 'git' args = [ 'add', '.'] } exec { executable = 'git' args = [ 'commit', '-m', 'Generated update.json'] } exec { executable = 'git' args = [ 'checkout', project.minecraft.version] } } } |
Java Spigot plugin:repo无关的.travis.yml & 自动更新maven repo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
language: java jdk: oraclejdk8 before_install: - git config --global user.name "Travis CI" - 'sed -i "s/^\(version: \).*$/\1$main_version.$TRAVIS_BUILD_NUMBER/g" src/main/resources/plugin.yml' after_success: - 'cp build/libs/nyaautils.jar ./nyaautils-$TRAVIS_BRANCH-v$main_version.$TRAVIS_BUILD_NUMBER.jar' before_deploy: - export GIT_TAG=$TRAVIS_BRANCH-v$main_version.$TRAVIS_BUILD_NUMBER - export GIT_ORIGIN_URL=`git config --get remote.origin.url` - git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER" - git config credential.helper "store --file=.git/credentials" - echo "https://$GITHUB_KEY:@github.com" > .git/credentials - git push -q --follow-tags - gem install octokit -v 4.3.0 - gradle publish - cd .. - git clone -b maven-repo $GIT_ORIGIN_URL nyaautils-mvn - cp -r nyaautils/build/repo/cat nyaautils-mvn/ - cd nyaautils-mvn - git config credential.helper "store --file=.git/credentials" - echo "https://$GITHUB_KEY:@github.com" > .git/credentials - git add . - git commit -m "auto generated maven repo" - git push --follow-tags - cd ../nyaautils deploy: - provider: releases skip_cleanup: true prerelease: true api_key: ${GITHUB_DEPLOY_KEY} file: './nyaautils-$TRAVIS_BRANCH-v$main_version.$TRAVIS_BUILD_NUMBER.jar' on: tags: false all_branches: true branches: except: - "/^*-v[0-9]/" - "maven-repo" env: global: - main_version=2 |
gz
[Dr.Lib]各种.travis.yml by Liqueur Librazy is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.