Skip to content

Commit

Permalink
Added release_buider (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovagorodok authored Nov 16, 2023
1 parent cfe9bf4 commit 7e1165a
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.pio
.vscode
.DS_Store
*.pyc
*.pyc
tools/release_builder/out
4 changes: 3 additions & 1 deletion examples/full/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

#define DEVICE_NAME "ArduinoBleOTA"

#ifdef ESP32
#ifdef ARDUINO_ARCH_ESP32
#define HW_NAME "Example ESP32"
#elif ARDUINO_ARCH_ATMELSAM
#define HW_NAME "Example ATMELSAM"
#else
#define HW_NAME "Example HW"
#endif
Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ lib_deps =
[env:nano_33_iot]
platform = atmelsam
board = nano_33_iot
build_flags =
-D ARDUINO_ARCH_ATMELSAM
lib_deps =
${env.lib_deps}
arduino-libraries/ArduinoBLE@^1.3.5
Expand Down
50 changes: 50 additions & 0 deletions tools/release_builder/example_hardware_atmelsam.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"hardware_name": "Example ATMELSAM",
"hardware_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"softwares": [
{

"software_name": "Example SW",
"software_version": [1, 0, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_example_v1.0.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"hardware_version": [1, 0, 0]
},
{
"software_name": "Example SW",
"software_version": [1, 1, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_example_v1.1.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"hardware_version": [1, 0, 0]
},
{
"software_name": "Example SW",
"software_version": [1, 1, 2],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_example_v1.1.2.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"min_hardware_version": [1, 0, 0],
"max_hardware_version": [1, 0, 2]
},
{
"software_name": "Example SW",
"software_version": [2, 0, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_example_v2.0.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"min_hardware_version": [2, 0, 0],
"max_hardware_version": [2, 0, 1]
},
{
"software_name": "Other SW",
"software_version": [1, 6, 6],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_other_v1.6.6.bin",
"min_hardware_version": [1, 0, 0],
"max_hardware_version": [1, 0, 3]
},
{
"software_name": "Experimental SW",
"software_version": [1, 1, 2],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_atmelsam_experimental_v1.1.2.bin",
"software_text": "Experimental branch of Example SW.\n\nChanges:\n- first\n- second"
}
]
}
50 changes: 50 additions & 0 deletions tools/release_builder/example_hardware_esp32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"hardware_name": "Example ESP32",
"hardware_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"softwares": [
{

"software_name": "Example SW",
"software_version": [1, 0, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_example_v1.0.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"hardware_version": [1, 0, 0]
},
{
"software_name": "Example SW",
"software_version": [1, 1, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_example_v1.1.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"hardware_version": [1, 0, 0]
},
{
"software_name": "Example SW",
"software_version": [1, 1, 2],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_example_v1.1.2.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"min_hardware_version": [1, 0, 0],
"max_hardware_version": [1, 0, 2]
},
{
"software_name": "Example SW",
"software_version": [2, 0, 0],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_example_v2.0.0.bin",
"software_icon": "https://raw.githubusercontent.com/vovagorodok/ble_ota_app/main/web/icons/Icon-192.png",
"min_hardware_version": [2, 0, 0],
"max_hardware_version": [2, 0, 1]
},
{
"software_name": "Other SW",
"software_version": [1, 6, 6],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_other_v1.6.6.bin",
"min_hardware_version": [1, 0, 0],
"max_hardware_version": [1, 0, 3]
},
{
"software_name": "Experimental SW",
"software_version": [1, 1, 2],
"software_path": "https://github.com/vovagorodok/ArduinoBleOTA/releases/download/v1.0.0/firmware_esp32_experimental_v1.1.2.bin",
"software_text": "Experimental branch of Example SW.\n\nChanges:\n- first\n- second"
}
]
}
58 changes: 58 additions & 0 deletions tools/release_builder/release_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

SCRIPT_DIR=$( cd $( dirname $0 ) && pwd )
OUT_DIR=$SCRIPT_DIR/out
PROJECT_DIR=$SCRIPT_DIR/../..
PIO_BUILD_DIR=$PROJECT_DIR/.pio/build
EXAMPLE_PATH=$PROJECT_DIR/examples/full/main.ino

source ~/.platformio/penv/bin/activate

rm -rf $OUT_DIR
mkdir -p $OUT_DIR
cd $PROJECT_DIR

change_example() {
FROM=$1
TO=$2
sed -i "s/$FROM/$TO/g" $EXAMPLE_PATH
}

build_firmware() {
BUILD_PLATFORM=$1
BUILD_ENV=$2
NEW_SW_NAME_AND_VER=$3
NEW_SW_NAME=$4
NEW_SW_VER=$5
NEW_HW_VER=$6
OLD_SW_NAME="Example SW"
OLD_SW_VER="SW_VER {1, 0, 0}"
OLD_HW_VER="HW_VER {1, 0, 0}"
BIN_PATH=$PIO_BUILD_DIR/$BUILD_ENV/firmware.bin

change_example "$OLD_SW_VER" "$NEW_SW_VER"
change_example "$OLD_HW_VER" "$NEW_HW_VER"
change_example "$OLD_SW_NAME" "$NEW_SW_NAME"

pio run -e $BUILD_ENV
mv $BIN_PATH $OUT_DIR/firmware_${BUILD_PLATFORM}_${NEW_SW_NAME_AND_VER}.bin

change_example "$NEW_SW_VER" "$OLD_SW_VER"
change_example "$NEW_HW_VER" "$OLD_HW_VER"
change_example "$NEW_SW_NAME" "$OLD_SW_NAME"
}

build_firmware_for_platform() {
BUILD_PLATFORM=$1
BUILD_ENV=$2

build_firmware $BUILD_PLATFORM $BUILD_ENV "example_v1.0.0" "Example SW" "SW_VER {1, 0, 0}" "HW_VER {1, 0, 0}"
build_firmware $BUILD_PLATFORM $BUILD_ENV "example_v1.1.0" "Example SW" "SW_VER {1, 1, 0}" "HW_VER {1, 0, 0}"
build_firmware $BUILD_PLATFORM $BUILD_ENV "example_v1.1.2" "Example SW" "SW_VER {1, 1, 2}" "HW_VER {1, 0, 0}"
build_firmware $BUILD_PLATFORM $BUILD_ENV "example_v2.0.0" "Example SW" "SW_VER {2, 0, 0}" "HW_VER {2, 0, 0}"
build_firmware $BUILD_PLATFORM $BUILD_ENV "experimental_v1.1.2" "Experimental SW" "SW_VER {1, 1, 2}" "HW_VER {1, 0, 0}"
build_firmware $BUILD_PLATFORM $BUILD_ENV "other_v1.6.6" "Other SW" "SW_VER {1, 6, 6}" "HW_VER {1, 0, 0}"
}

build_firmware_for_platform "esp32" "esp32dev"
build_firmware_for_platform "atmelsam" "nano_33_iot"

0 comments on commit 7e1165a

Please sign in to comment.