Merge pull request #1101 from tannewt/patch-1
[betaflight.git] / .travis.sh
blobbd274e59f5e1bcba89eb79c27afb766c847dfc72
1 #!/bin/bash
3 REVISION=$(git rev-parse --short HEAD)
4 BRANCH=$(git rev-parse --abbrev-ref HEAD)
5 REVISION=$(git rev-parse --short HEAD)
6 LAST_COMMIT_DATE=$(git log -1 --date=short --format="%cd")
7 TARGET_FILE=obj/cleanflight_${TARGET}
8 TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG:=$USER/undefined}
9 BUILDNAME=${BUILDNAME:=travis}
10 TRAVIS_BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:=undefined}
12 CURL_BASEOPTS=(
13 "--retry" "10"
14 "--retry-max-time" "120" )
16 CURL_PUB_BASEOPTS=(
17 "--form" "revision=${REVISION}"
18 "--form" "branch=${BRANCH}"
19 "--form" "travis_build_number=${TRAVIS_BUILD_NUMBER}"
20 "--form" "last_commit_date=${LAST_COMMIT_DATE}"
21 "--form" "github_repo=${TRAVIS_REPO_SLUG}"
22 "--form" "build_name=${BUILDNAME}" )
24 # A hacky way of running the unit tests at the same time as the normal builds.
25 if [ $RUNTESTS ] ; then
26 cd ./src/test && make test
28 # A hacky way of building the docs at the same time as the normal builds.
29 elif [ $PUBLISHDOCS ] ; then
30 if [ $PUBLISH_URL ] ; then
32 sudo apt-get install zlib1g-dev libssl-dev wkhtmltopdf libxml2-dev libxslt-dev #ruby-rvm
34 # Patch Gimli to fix underscores_inside_words
35 curl -L "${CURL_BASEOPTS[@]}" https://github.com/walle/gimli/archive/v0.5.9.tar.gz | tar zxf -
37 sed -i 's/).render(/, :no_intra_emphasis => true).render(/' gimli-0.5.9/ext/github_markup.rb
39 cd gimli-0.5.9/
40 gem build gimli.gemspec && rvmsudo gem install gimli
41 cd ../
43 ./build_docs.sh
45 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "manual=@docs/Manual.pdf" ${PUBLISH_URL} || true
48 elif [ $PUBLISHMETA ] ; then
49 if [ $PUBLISH_URL ] ; then
50 RECENT_COMMITS=$(git shortlog -n25)
51 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true
54 else
55 if [ $PUBLISH_URL ] ; then
56 make -j2
57 if [ -f ${TARGET_FILE}.bin ] ; then
58 TARGET_FILE=${TARGET_FILE}.bin
59 elif [ -f ${TARGET_FILE}.hex ] ; then
60 TARGET_FILE=${TARGET_FILE}.hex
61 else
62 echo "build artifact (hex or bin) for ${TARGET_FILE} not found, aborting";
63 exit 1
66 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true
67 exit 0;
68 else
69 make -j2