Travis artefacts (#564)

* Try artefacts deployed to gh_pages

* Try to use gh_pages from the travis_artefacts branch

* Try deploying to a different repo

* Try to organise files deployed to github pages

* Test pushing a local dir to master

* Try pushing to original repo

* Be verbose so I can debug it

* Setting env variables

* Oops, environment variables aren't what I thought

* Try to push to nightly repo

* Remove unused cp command

* Copy firmware to archive directory

* Fix pathing to artefacts

* Use TRAVIS_BUID_DIR instead of assuming path

* Use mkdir -p to ensure directories exist

* Put / back in to CPLD path

* Move repo to GSG

* Switch to master branch

* Add nightly deployment

* Fix escaping in sed command

* Allow firmware version styring to be overridden

* Fix some sed commands....

* Switch to master branch for builds
This commit is contained in:
Dominic Spill
2018-12-20 20:38:10 -07:00
committed by Michael Ossmann
parent 847d00d770
commit 454e32b8c8
3 changed files with 110 additions and 19 deletions

View File

@ -10,6 +10,14 @@ matrix:
- os: osx
compiler: clang
env:
global:
- SHORT_COMMIT_HASH=`git rev-parse --short HEAD`
- VERSION_STRING=nightly-$SHORT_COMMIT_HASH
- BUILD_NAME="HackRF-`date +%Y-%m-%d`-$SHORT_COMMIT_HASH"
- ARTEFACT_BASE=$TRAVIS_BUILD_DIR/artefacts/
- ARTEFACT_PATH=$ARTEFACT_BASE/$BUILD_NAME
addons:
apt:
packages:
@ -35,15 +43,19 @@ before_script:
- export CFLAGS="-Wall -Wextra -Werror"
script:
# Host code
- mkdir host/build
- cd host/build
- cmake ..
- make
- cd ../..
- mkdir firmware/build-hackrf-one
- mkdir firmware/build-jawbreaker
- mkdir firmware/build-rad1o
- cd firmware/libopencm3
# Firmware
# Set version string
- cd ../../firmware
- sed -e "s/\#set(VERSION.*/set(VERSION \"$VERSION_STRING\")/" -i".bak" hackrf-common.cmake
- mkdir build-hackrf-one
- mkdir build-jawbreaker
- mkdir build-rad1o
- cd libopencm3
- make
- cd ../build-hackrf-one
- cmake ..
@ -54,3 +66,31 @@ script:
- cd ../build-rad1o
- cmake -DBOARD=RAD1O ..
- make
after_success:
# Construct archive for deploying to ubertooth-nightlies
- mkdir -p $ARTEFACT_PATH/firmware-bin/
# Export HackRF git repo
- cd $TRAVIS_BUILD_DIR/
- git archive --format=tar HEAD | (cd $ARTEFACT_PATH && tar xf -)
# Set version string
- sed -e "s/\#set(RELEASE.*/set(RELEASE \"$VERSION_STRING\")/" -i".bak" $ARTEFACT_PATH/host/cmake/set_release.cmake
# Copy firmware to firmware-bin directory
- cd $TRAVIS_BUILD_DIR/firmware/
- cp cpld/sgpio_if/default.xsvf $ARTEFACT_PATH/firmware-bin/hackrf_cpld_default.xsvf
- cp build-hackrf-one/hackrf_usb/hackrf_usb.bin $ARTEFACT_PATH/firmware-bin/hackrf_one_usb.bin
- cp build-hackrf-one/hackrf_usb/hackrf_usb.dfu $ARTEFACT_PATH/firmware-bin/hackrf_one_usb.dfu
- cp build-jawbreaker/hackrf_usb/hackrf_usb.bin $ARTEFACT_PATH/firmware-bin/hackrf_jawbreaker_usb.bin
- cp build-jawbreaker/hackrf_usb/hackrf_usb.dfu $ARTEFACT_PATH/firmware-bin/hackrf_jawbreaker_usb.dfu
- cp build-rad1o/hackrf_usb/hackrf_usb.bin $ARTEFACT_PATH/firmware-bin/rad1o_usb.bin
- cp build-rad1o/hackrf_usb/hackrf_usb.dfu $ARTEFACT_PATH/firmware-bin/rad1o_usb.dfu
# Build the archive
- cd $ARTEFACT_BASE
- tar -cJvf $ARTEFACT_BASE/$BUILD_NAME.tar.xz $BUILD_NAME
deploy:
provider: script
skip-cleanup: true
script: bash $TRAVIS_BUILD_DIR/tools/deploy-nightly.sh
on:
branch: master

View File

@ -34,6 +34,8 @@ SET(LIBOPENCM3 ${PATH_HACKRF_FIRMWARE}/libopencm3)
include(${PATH_HACKRF_FIRMWARE}/dfu-util.cmake)
#set(VERSION "")
if (NOT DEFINED VERSION)
execute_process(
COMMAND git log -n 1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
@ -45,8 +47,9 @@ execute_process(
if (GIT_VERSION_FOUND)
set(VERSION "unknown")
else (GIT_VERSION_FOUND)
set(VERSION ${GIT_VERSION})
set(VERSION "git-${GIT_VERSION}")
endif (GIT_VERSION_FOUND)
endif()
if(NOT DEFINED BOARD)
set(BOARD HACKRF_ONE)
@ -62,7 +65,7 @@ if(NOT DEFINED SRC_M0)
set(SRC_M0 "${PATH_HACKRF_FIRMWARE_COMMON}/m0_sleep.c")
endif()
SET(HACKRF_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -DTX_ENABLE -D'VERSION_STRING=\"git-${VERSION}\"'")
SET(HACKRF_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -DTX_ENABLE -D'VERSION_STRING=\"${VERSION}\"'")
SET(LDSCRIPT_M4 "-T${PATH_HACKRF_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx_rom_to_ram.ld -T${PATH_HACKRF_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")

48
tools/deploy-nightly.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
REPO=greatscottgadgets/hackrf-nightly
PUBLICATION_BRANCH=master
# set -x
cd $HOME
# Checkout the branch
git clone --branch=$PUBLICATION_BRANCH https://${GITHUB_TOKEN}@github.com/$REPO.git publish
cd publish
# Update pages
cp $ARTEFACT_BASE/$BUILD_NAME.tar.xz .
# Write index page
cd $TRAVIS_BUILD_DIR
COMMITS=`git log --oneline | awk '{print $1}'`
cd $HOME/publish
echo "
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html><head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
<title>HackRF Nightly Builds</title>
</head>
<body>
<h2>HackRF Nightly Builds</h2>
" > index.html
URL=https://greatscottgadgets.github.io/hackrf-nightly
for commit in $COMMITS; do
FILENAME=`find . -maxdepth 1 -name "*-$commit.tar.xz"`
if [ "$FILENAME" != "" ]; then
FN=${FILENAME:2}
echo "<a href=\"$URL/$FN\">$FN</a><br />" >> index.html
fi
done
echo "
</body></html>
" >> index.html
# Commit and push latest version
git add $BUILD_NAME.tar.xz index.html
git config user.name "Travis"
git config user.email "travis@travis-ci.org"
git commit -m "Build products for $SHORT_COMMIT_HASH, built on $TRAVIS_OS_NAME, log: $TRAVIS_BUILD_WEB_URL"
if [ "$?" != "0" ]; then
echo "Looks like the commit failed"
fi
git push -fq origin $PUBLICATION_BRANCH