Skip to content

Commit dacd718

Browse files
committed
package: add script to build and deploy nightly packages
1 parent 4b0cef5 commit dacd718

File tree

5 files changed

+134
-45
lines changed

5 files changed

+134
-45
lines changed

.travis.yml

+3-34
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ sudo: false
22
language: bash
33
os:
44
- linux
5+
env:
6+
- BUILD_TYPE=build
57

68
addons:
79
apt:
@@ -11,40 +13,7 @@ addons:
1113
- g++-4.8
1214

1315
script:
14-
- set -e
15-
- export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"
16-
- echo -e "travis_fold:start:host_tests"
17-
- pushd $TRAVIS_BUILD_DIR/tests/host
18-
- make
19-
- make clean-objects
20-
- echo -e "travis_fold:end:host_tests"
21-
- echo -e "travis_fold:start:sketch_test_env_prepare"
22-
- popd
23-
- wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
24-
- tar xf arduino.tar.xz
25-
- mv arduino-nightly $HOME/arduino_ide
26-
- cd $HOME/arduino_ide/hardware
27-
- mkdir esp8266com
28-
- cd esp8266com
29-
- ln -s $TRAVIS_BUILD_DIR esp8266
30-
- cd esp8266/tools
31-
- python get.py
32-
- export PATH="$HOME/arduino_ide:$TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf/bin:$PATH"
33-
- which arduino
34-
- cd $TRAVIS_BUILD_DIR
35-
- source tests/common.sh
36-
- install_libraries
37-
- echo -e "travis_fold:end:sketch_test_env_prepare"
38-
- echo -e "travis_fold:start:sketch_test"
39-
- build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
40-
- echo -e "travis_fold:end:sketch_test"
41-
- echo -e "travis_fold:start:size_report"
42-
- cat size.log
43-
- echo -e "travis_fold:end:size_report"
44-
45-
after_success:
46-
- pushd $TRAVIS_BUILD_DIR/tests/host
47-
- bash <(curl -s https://codecov.io/bash) -X gcov
16+
- $TRAVIS_BUILD_DIR/tests/common.sh
4817

4918
notifications:
5019
email:

package/build_boards_manager_package.sh

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
#
3-
next="2.4.0"
3+
4+
# Extract next version from platform.txt
5+
next=`sed -n -E 's/version=([0-9.]+)/\1/p' ../platform.txt`
46

57
# Figure out how will the package be called
68
ver=`git describe --exact-match`
@@ -27,14 +29,14 @@ fi
2729
echo "Remote: $REMOTE_URL"
2830

2931
if [ -z "$PKG_URL" ]; then
30-
PKG_URL="$REMOTE_URL/versions/$ver/$package_name.zip"
32+
if [ -z "$PKG_URL_PREFIX" ]; then
33+
PKG_URL_PREFIX="$REMOTE_URL/versions/$ver"
34+
fi
35+
PKG_URL="$PKG_URL_PREFIX/$package_name.zip"
3136
fi
3237
echo "Package: $PKG_URL"
33-
34-
if [ -z "$DOC_URL" ]; then
35-
DOC_URL="$REMOTE_URL/versions/$ver/doc/reference.html"
36-
fi
3738
echo "Docs: $DOC_URL"
39+
3840
pushd ..
3941
# Create directory for the package
4042
outdir=package/versions/$ver/$package_name
@@ -82,7 +84,7 @@ $SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \
8284
> $outdir/platform.txt
8385

8486
# Put core version and short hash of git version into core_version.h
85-
ver_define=`echo $plain_ver | tr "[:lower:].-+" "[:upper:]_"`
87+
ver_define=`echo $plain_ver | tr "[:lower:].\055" "[:upper:]_"`
8688
echo Ver define: $ver_define
8789
echo \#define ARDUINO_ESP8266_GIT_VER 0x`git rev-parse --short=8 HEAD 2>/dev/null` >$outdir/cores/esp8266/core_version.h
8890
echo \#define ARDUINO_ESP8266_RELEASE_$ver_define >>$outdir/cores/esp8266/core_version.h
@@ -104,22 +106,30 @@ echo "Making package_esp8266com_index.json"
104106

105107
jq_arg=".packages[0].platforms[0].version = \"$ver\" | \
106108
.packages[0].platforms[0].url = \"$PKG_URL\" |\
107-
.packages[0].platforms[0].archiveFileName = \"$package_name.zip\" |\
108-
.packages[0].platforms[0].help.online = \"$DOC_URL\""
109+
.packages[0].platforms[0].archiveFileName = \"$package_name.zip\""
109110

110111
if [ -z "$is_nightly" ]; then
111112
jq_arg="$jq_arg |\
112113
.packages[0].platforms[0].size = \"$size\" |\
113114
.packages[0].platforms[0].checksum = \"SHA-256:$sha\" |"
114115
fi
115116

117+
if [ ! -z "$DOC_URL" ]; then
118+
jq_arg="$jq_arg |\
119+
.packages[0].platforms[0].help.online = \"$DOC_URL\""
120+
fi
121+
116122
cat $srcdir/package/package_esp8266com_index.template.json | \
117123
jq "$jq_arg" > package_esp8266com_index.json
118124

119125
old_json=package_esp8266com_index_stable.json
120-
wget -O $old_json http://arduino.esp8266.com/$branch/package_esp8266com_index.json
126+
for i in $(seq 1 5); do
127+
echo "Downloading old package, try $i"
128+
curl -L -o $old_json http://arduino.esp8266.com/stable/package_esp8266com_index.json && break
129+
done
121130
new_json=package_esp8266com_index.json
122131

132+
set +e
123133
python ../../merge_packages.py $new_json $old_json >tmp && mv tmp $new_json && rm $old_json
124134

125135
popd

package/deploy_nightly_package.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -e
4+
export PKG_URL_PREFIX=https://dl.bintray.com/igrr/arduino-esp8266/:
5+
commit=`git rev-parse --short HEAD`
6+
7+
./build_boards_manager_package.sh
8+
9+
ver=`ls -1 versions`
10+
bintray_slug=igrr/arduino-esp8266/arduino-esp8266-core
11+
12+
# Upload to bintray
13+
# URL to the file will look like this: https://dl.bintray.com/igrr/arduino-esp8266/:esp8266-2.4.0-nightly+20170218.zip
14+
curl --progress-bar \
15+
-T versions/$ver/esp8266-$ver.zip \
16+
-uigrr:$BINTRAY_API_KEY \
17+
-o curl.out \
18+
https://api.bintray.com/content/$bintray_slug/$ver/esp8266-$ver.zip
19+
20+
21+
# Publish the uploaded file
22+
curl -uigrr:$BINTRAY_API_KEY \
23+
-X POST \
24+
https://api.bintray.com/content/$bintray_slug/$ver/publish
25+
26+
# Load deploy key
27+
echo -n $ESP8266_ARDUINO_DEPLOY_KEY_B64 > ~/.ssh/esp8266_arduino_deploy_b64
28+
base64 --decode --ignore-garbage ~/.ssh/esp8266_arduino_deploy_b64 > ~/.ssh/esp8266_arduino_deploy
29+
chmod 600 ~/.ssh/esp8266_arduino_deploy
30+
echo -e "Host $DEPLOY_HOST_NAME\n\tUser $DEPLOY_USER_NAME\n\tStrictHostKeyChecking no\n\tIdentityFile ~/.ssh/esp8266_arduino_deploy" >> ~/.ssh/config
31+
32+
# Generate the badge (used in Readme.md)
33+
release_date=$(date "+%b_%d,_%Y")
34+
curl -o versions/$ver/badge.svg https://img.shields.io/badge/updated-$release_date-blue.svg
35+
36+
# Check old version
37+
oldver=$(ssh $DEPLOY_HOST_NAME "cat $DEPLOY_PATH_NIGHTLY/version")
38+
39+
if [ "$oldver" = "$ver" ]; then
40+
echo "Nightly version hasn't changed, not updating"
41+
else
42+
# Upload new json, version file, and the badge
43+
echo $ver > versions/$ver/version
44+
scp versions/$ver/{package_esp8266com_index.json,version,badge.svg} $DEPLOY_HOST_NAME:$DEPLOY_PATH_NIGHTLY/
45+
curl --data-urlencode "message=Updating **nightly** package from $oldver to $ver" $GITTER_WEBHOOK
46+
fi

platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
77

88
name=ESP8266 Modules
9-
version=2.3.0
9+
version=2.4.0
1010

1111
runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf
1212
runtime.tools.esptool.path={runtime.platform.path}/tools/esptool

tests/common.sh

+64
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,67 @@ function install_libraries()
8484

8585
popd
8686
}
87+
88+
function install_ide()
89+
{
90+
local ide_path=$1
91+
local core_path=$2
92+
wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
93+
tar xf arduino.tar.xz
94+
mv arduino-nightly $ide_path
95+
cd $ide_path/hardware
96+
mkdir esp8266com
97+
cd esp8266com
98+
ln -s $core_path esp8266
99+
cd esp8266/tools
100+
python get.py
101+
export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH"
102+
}
103+
104+
function run_host_tests()
105+
{
106+
pushd host
107+
make
108+
make clean-objects
109+
popd
110+
}
111+
112+
113+
function run_travis_ci_build()
114+
{
115+
export CXX="g++-4.8" CC="gcc-4.8" GCOV="gcov-4.8"
116+
echo -e "travis_fold:start:host_tests"
117+
cd $TRAVIS_BUILD_DIR/tests
118+
run_host_tests
119+
echo -e "travis_fold:end:host_tests"
120+
echo -e "travis_fold:start:sketch_test_env_prepare"
121+
cd $TRAVIS_BUILD_DIR
122+
install_ide $HOME/arduino_ide $TRAVIS_BUILD_DIR
123+
which arduino
124+
cd $TRAVIS_BUILD_DIR
125+
install_libraries
126+
echo -e "travis_fold:end:sketch_test_env_prepare"
127+
echo -e "travis_fold:start:sketch_test"
128+
build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
129+
echo -e "travis_fold:end:sketch_test"
130+
echo -e "travis_fold:start:size_report"
131+
cat size.log
132+
echo -e "travis_fold:end:size_report"
133+
pushd $TRAVIS_BUILD_DIR/tests/host
134+
bash <(curl -s https://codecov.io/bash) -X gcov
135+
}
136+
137+
function deploy_nightly_package()
138+
{
139+
cd $TRAVIS_BUILD_DIR/package
140+
./deploy_nightly_package.sh
141+
}
142+
143+
set -e
144+
145+
if [ "$BUILD_TYPE" = "deploy_nightly_package" ]; then
146+
deploy_nightly_package
147+
elif [ "$BUILD_TYPE" = "build" ]; then
148+
run_travis_ci_build
149+
fi
150+

0 commit comments

Comments
 (0)