Skip to content

Commit a3a7e87

Browse files
committed
ci: build and upload releases on Travis
1 parent d7044ec commit a3a7e87

6 files changed

+171
-60
lines changed

.travis.yml

+18-37
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,29 @@
11
sudo: false
22
language: bash
3-
os:
4-
- linux
5-
3+
os: linux
64
dist: trusty
75

6+
env:
7+
- BUILD_TYPE=build
8+
89
install:
910
- pip install --user -r doc/requirements.txt
1011

1112
script:
12-
- set -e
13-
- echo -e "travis_fold:start:docs"
14-
- pushd $TRAVIS_BUILD_DIR/doc
15-
- SPHINXOPTS="-W" make html
16-
- popd
17-
- echo -e "travis_fold:end:docs"
18-
- echo -e "travis_fold:start:host_tests"
19-
- pushd $TRAVIS_BUILD_DIR/tests/host
20-
- make
21-
- make clean-objects
22-
- popd
23-
- echo -e "travis_fold:end:host_tests"
24-
- echo -e "travis_fold:start:sketch_test_env_prepare"
25-
- wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
26-
- tar xf arduino.tar.xz
27-
- mv arduino-nightly $HOME/arduino_ide
28-
- cd $HOME/arduino_ide/hardware
29-
- mkdir esp8266com
30-
- cd esp8266com
31-
- ln -s $TRAVIS_BUILD_DIR esp8266
32-
- cd esp8266/tools
33-
- python get.py
34-
- export PATH="$HOME/arduino_ide:$TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf/bin:$PATH"
35-
- which arduino
36-
- cd $TRAVIS_BUILD_DIR
37-
- source tests/common.sh
38-
- install_libraries
39-
- echo -e "travis_fold:end:sketch_test_env_prepare"
40-
- echo -e "travis_fold:start:sketch_test"
41-
- build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
42-
- echo -e "travis_fold:end:sketch_test"
43-
- echo -e "travis_fold:start:size_report"
44-
- cat size.log
45-
- echo -e "travis_fold:end:size_report"
13+
- $TRAVIS_BUILD_DIR/tests/common.sh
14+
15+
deploy:
16+
provider: releases
17+
prerelease: true
18+
api_key:
19+
secure: A4FBmqyhlzy33oPeZVolg2Q/A3ZcJ3WnRQqQJ3NAPy+qGM5xcboOYtwcLL9vKaHZGfUB7lUP9QVZFGou1Wrmo9DnPvAoe3+XvCaDRGzVMxeIpu7UStbBD4Knbh98tlbMvZCXYRlT4VcusI9bMLK6UWw4sMdPislBh2FEfglTiag=
20+
file_glob: true
21+
file:
22+
- package/versions/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
23+
- package/versions/$TRAVIS_TAG/package_esp8266com_index.json
24+
on:
25+
repo: esp8266/Arduino
26+
tags: true
4627

4728
notifications:
4829
email:

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ Boards manager link: `http://arduino.esp8266.com/stable/package_esp8266com_index
3838

3939
Documentation: [http://esp8266.github.io/Arduino/versions/2.3.0/](http://esp8266.github.io/Arduino/versions/2.3.0/)
4040

41-
##### Staging version ![](http://arduino.esp8266.com/staging/badge.svg)
42-
Boards manager link: `http://arduino.esp8266.com/staging/package_esp8266com_index.json`
43-
44-
Documentation: [http://esp8266.github.io/Arduino/versions/2.3.0-rc2/](http://esp8266.github.io/Arduino/versions/2.3.0-rc2/)
45-
4641
### Using git version
4742
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino) [![codecov.io](https://codecov.io/github/esp8266/Arduino/coverage.svg?branch=master)](https://codecov.io/github/esp8266/Arduino?branch=master)
4843

package/build_boards_manager_package.sh

+64-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#!/bin/bash
22
#
33

4+
# Extract next version from platform.txt
5+
next=`sed -n -E 's/version=([0-9.]+)/\1/p' ../platform.txt`
6+
47
# Figure out how will the package be called
5-
ver=`git describe --tags --always`
8+
ver=`git describe --exact-match`
9+
if [ $? -ne 0 ]; then
10+
# not tagged version; generate nightly package
11+
date_str=`date +"%Y%m%d"`
12+
is_nightly=1
13+
plain_ver="${next}-nightly"
14+
ver="${plain_ver}+${date_str}"
15+
else
16+
plain_ver=$ver
17+
fi
18+
619
package_name=esp8266-$ver
720
echo "Version: $ver"
821
echo "Package name: $package_name"
@@ -16,14 +29,14 @@ fi
1629
echo "Remote: $REMOTE_URL"
1730

1831
if [ -z "$PKG_URL" ]; then
19-
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"
2036
fi
2137
echo "Package: $PKG_URL"
22-
23-
if [ -z "$DOC_URL" ]; then
24-
DOC_URL="$REMOTE_URL/versions/$ver/doc/reference.html"
25-
fi
2638
echo "Docs: $DOC_URL"
39+
2740
pushd ..
2841
# Create directory for the package
2942
outdir=package/versions/$ver/$package_name
@@ -37,6 +50,7 @@ cat << EOF > exclude.txt
3750
.gitignore
3851
.travis.yml
3952
package
53+
doc
4054
EOF
4155
# Also include all files which are ignored by git
4256
git ls-files --other --directory >> exclude.txt
@@ -47,7 +61,7 @@ rm exclude.txt
4761
# Get additional libraries (TODO: add them as git submodule or subtree?)
4862

4963
# SoftwareSerial library
50-
wget -q -O SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/3.1.0.zip
64+
curl -L -o SoftwareSerial.zip https://github.com/plerup/espsoftwareserial/archive/3.1.0.zip
5165
unzip -q SoftwareSerial.zip
5266
rm -rf SoftwareSerial.zip
5367
mv espsoftwareserial-* SoftwareSerial
@@ -71,7 +85,7 @@ $SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' \
7185
> $outdir/platform.txt
7286

7387
# Put core version and short hash of git version into core_version.h
74-
ver_define=`echo $ver | tr "[:lower:].-" "[:upper:]_"`
88+
ver_define=`echo $plain_ver | tr "[:lower:].\055" "[:upper:]_"`
7589
echo Ver define: $ver_define
7690
echo \#define ARDUINO_ESP8266_GIT_VER 0x`git rev-parse --short=8 HEAD 2>/dev/null` >$outdir/cores/esp8266/core_version.h
7791
echo \#define ARDUINO_ESP8266_RELEASE_$ver_define >>$outdir/cores/esp8266/core_version.h
@@ -90,14 +104,49 @@ echo Size: $size
90104
echo SHA-256: $sha
91105

92106
echo "Making package_esp8266com_index.json"
93-
cat $srcdir/package/package_esp8266com_index.template.json | \
94-
jq ".packages[0].platforms[0].version = \"$ver\" | \
107+
108+
jq_arg=".packages[0].platforms[0].version = \"$ver\" | \
95109
.packages[0].platforms[0].url = \"$PKG_URL\" |\
96-
.packages[0].platforms[0].archiveFileName = \"$package_name.zip\" |\
97-
.packages[0].platforms[0].checksum = \"SHA-256:$sha\" |\
98-
.packages[0].platforms[0].size = \"$size\" |\
99-
.packages[0].platforms[0].help.online = \"$DOC_URL\"" \
100-
> package_esp8266com_index.json
110+
.packages[0].platforms[0].archiveFileName = \"$package_name.zip\""
111+
112+
if [ -z "$is_nightly" ]; then
113+
jq_arg="$jq_arg |\
114+
.packages[0].platforms[0].size = \"$size\" |\
115+
.packages[0].platforms[0].checksum = \"SHA-256:$sha\""
116+
fi
117+
118+
if [ ! -z "$DOC_URL" ]; then
119+
jq_arg="$jq_arg |\
120+
.packages[0].platforms[0].help.online = \"$DOC_URL\""
121+
fi
122+
123+
cat $srcdir/package/package_esp8266com_index.template.json | \
124+
jq "$jq_arg" > package_esp8266com_index.json
125+
126+
# Get previous release name
127+
curl --silent https://api.github.com/repos/esp8266/Arduino/releases > releases.json
128+
# Previous final release (prerelase == false)
129+
prev_release=$(jq -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' releases.json)
130+
# Previous release (possibly a pre-release)
131+
prev_any_release=$(jq -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' releases.json)
132+
# Previous pre-release
133+
prev_pre_release=$(jq -r '. | map(select(.draft == false and .prerelease == true)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' releases.json)
134+
135+
echo "Previous release: $prev_release"
136+
echo "Previous (pre-?)release: $prev_any_release"
137+
echo "Previous pre-release: $prev_pre_release"
138+
139+
# Make all released versions available in one package (i.e. don't separate stable/staging versions)
140+
base_ver=$prev_any_release
141+
142+
# Download previous release
143+
echo "Downloading base package: $base_ver"
144+
old_json=package_esp8266com_index_stable.json
145+
curl -L -o $old_json "https://github.com/esp8266/Arduino/releases/download/${base_ver}/package_esp8266com_index.json"
146+
new_json=package_esp8266com_index.json
147+
148+
set +e
149+
python ../../merge_packages.py $new_json $old_json >tmp && mv tmp $new_json && rm $old_json
101150

102151
popd
103152
popd

package/package_esp8266com_index.template.json

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
"category": "ESP8266",
1717
"url": "",
1818
"archiveFileName": "",
19-
"checksum": "",
20-
"size": "",
2119
"help": {
2220
"online": ""
2321
},

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

+88
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,91 @@ 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 build_docs()
105+
{
106+
SPHINXOPTS="-W" make html
107+
}
108+
109+
function run_host_tests()
110+
{
111+
pushd host
112+
make
113+
make clean-objects
114+
popd
115+
}
116+
117+
function build_package()
118+
{
119+
export PKG_URL=https://github.com/esp8266/Arduino/releases/download/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
120+
export DOC_URL=https://arduino-esp8266.readthedocs.io/en/$TRAVIS_TAG/
121+
./build_boards_manager_package.sh
122+
}
123+
124+
function run_travis_ci_build()
125+
{
126+
# Build documentation using Sphinx
127+
echo -e "travis_fold:start:docs"
128+
cd $TRAVIS_BUILD_DIR/doc
129+
build_docs
130+
echo -e "travis_fold:end:docs"
131+
132+
# Build release package
133+
echo -e "travis_fold:start:build_package"
134+
cd $TRAVIS_BUILD_DIR/package
135+
build_package
136+
echo -e "travis_fold:end:build_package"
137+
138+
if [ "$TRAVIS_TAG" != "" ]; then
139+
echo "Skipping tests for tagged build"
140+
return 0;
141+
fi
142+
143+
# Run host side tests
144+
echo -e "travis_fold:start:host_tests"
145+
cd $TRAVIS_BUILD_DIR/tests
146+
run_host_tests
147+
echo -e "travis_fold:end:host_tests"
148+
149+
# Install Arduino IDE and required libraries
150+
echo -e "travis_fold:start:sketch_test_env_prepare"
151+
cd $TRAVIS_BUILD_DIR
152+
install_ide $HOME/arduino_ide $TRAVIS_BUILD_DIR
153+
which arduino
154+
cd $TRAVIS_BUILD_DIR
155+
install_libraries
156+
echo -e "travis_fold:end:sketch_test_env_prepare"
157+
158+
# Compile sketches
159+
echo -e "travis_fold:start:sketch_test"
160+
build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
161+
echo -e "travis_fold:end:sketch_test"
162+
163+
# Generate size report
164+
echo -e "travis_fold:start:size_report"
165+
cat size.log
166+
echo -e "travis_fold:end:size_report"
167+
}
168+
169+
set -e
170+
171+
if [ "$BUILD_TYPE" = "build" ]; then
172+
run_travis_ci_build
173+
fi
174+

0 commit comments

Comments
 (0)