forked from letscontrolit/ESPEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
before_deploy
executable file
·103 lines (88 loc) · 2.32 KB
/
before_deploy
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
VERSION=$(git describe)
TMP_DIST=`mktemp -d`
CURPATH=`pwd`
while getopts d: option
do
case "${option}"
in
d) VERSION=${OPTARG};;
esac
done
if [ ! -d ${TMP_DIST} ]; then
# Could not create temp dir, so exit
exit 1
fi
#Naming convention:
# ESP_Easy_[github version]_[plugin set]_[chip type]_[flash memory].bin
mkdir -p ${TMP_DIST}
cp -r dist/* ${TMP_DIST}/
if [ -d "docs/build" ]; then
# Docs have been created
mkdir -p ${TMP_DIST}/docs
cp -r docs/build/* ${TMP_DIST}/docs/
fi
for ENV in \
esp-wrover-kit_test_1M8_partition\
esp32dev\
esp32test_1M8_partition\
normal_ESP8266_1024\
normal_ESP8266_1024_VCC\
minimal_ESP8266_1024_OTA\
minimal_ESP8285_1024_OTA\
normal_ESP8285_1024\
normal_ESP8266_4096\
normal_IR_ESP8266_4096\
test_ESP8266_4096\
test_ESP8266_4096_VCC\
dev_ESP8266_4096\
hard_SONOFF_POW_4M\
normal_core_241_ESP8266_4096\
normal_core_241_ESP8266_1024\
normal_core_250_beta_ESP8266_4096\
normal_core_250_beta_ESP8266_1024\
normal_core_250_beta_IR_ESP8266_4096\
test_core_250_beta_ESP8266_4096\
test_core_250_beta_ESP8266_4096_VCC\
hard_core_250_beta_SONOFF_POW_4M\
hard_core_250_beta_Shelly_1;\
do
MAX_FILESIZE=1044464
if [[ ${ENV} == *"1024"* ]]; then
# max 602 kiB
MAX_FILESIZE=892912
fi
if [[ ${ENV} == *"1024_OTA"* ]]; then
# max 602 kiB
MAX_FILESIZE=616448
fi
if [[ ${ENV} == *"esp32"* ]]; then
MAX_FILESIZE=1310720
fi
if [[ ${ENV} == *"1M8_partition"* ]]; then
MAX_FILESIZE=1900544
fi
FILESIZE=$(stat -c%s .pioenvs/${ENV}/firmware.bin )
if (( FILESIZE < MAX_FILESIZE )); then
echo
echo "### Deploying environment $ENV for version $VERSION"
BIN=.pioenvs/${ENV}/ESP_Easy_${VERSION}_${ENV}.bin
cp .pioenvs/${ENV}/firmware.bin $BIN
python2 crc2.py $BIN
mv $BIN "${TMP_DIST}/bin/ESP_Easy_${VERSION}_${ENV}.bin"
else
echo "Build too large for $ENV $FILESIZE > $MAX_FILESIZE "
fi
done
#create a source structure that is the same as the original ESPEasy project (and works with the howto on the wiki)
#rm -rf dist/Source 2>/dev/null
mkdir -p ${TMP_DIST}/source
cp -r lib ${TMP_DIST}/source/
cp -r src ${TMP_DIST}/source/
cp platformio.ini ${TMP_DIST}/source/
cd ${TMP_DIST}
echo
echo "### Creating zip archive"
zip ${CURPATH}/ESPEasy_$VERSION.zip -r .
rm -Rf ${TMP_DIST}/* 2>/dev/null
rmdir ${TMP_DIST}