Skip to content

Commit

Permalink
Add base configuration and deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed May 11, 2018
1 parent b458720 commit 10f9f65
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
71 changes: 71 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[platformio]
env_default = debug

;
; Configuration
; PLEASE REPLACE ALL (bintray/wifi) *** WITH REAL VALUES
;

; Please navigate to https://bintray.com/, create an account,
; repository, and add a package where PlatformIO will deploy firmwares
; api_token = Bintray.com > Edit Profile > API Key
[bintray]
user = ***
repository = ***
package = ***
api_token = ***

; Wi-Fi network settings
[wifi]
ssid = ***
password = ***

[common]
; firmware version, please modify it between releases
; positive integer value
version = 0

; build configuration based on Bintray and Wi-Fi settings
build_flags =
'-DWIFI_SSID="${wifi.ssid}"'
'-DWIFI_PASS="${wifi.password}"'
'-DBINTRAY_USER="${bintray.user}"'
'-DBINTRAY_REPO="${bintray.repository}"'
'-DBINTRAY_PACKAGE="${bintray.package}"'
-DVERSION=${common.version}

; extra dependencies
lib_deps = ArduinoJson

;
; Build environments
;

[env:debug]
platform = espressif32
framework = arduino
board = esp32dev
build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_baud = 115200
upload_speed = 921600
; upload_protocol = olimex-arm-usb-tiny-h
; debug_tool = olimex-arm-usb-tiny-h

[env:release]
platform = espressif32
framework = arduino
board = esp32dev
build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
upload_protocol = custom
extra_scripts = pre:publish_firmware.py
67 changes: 67 additions & 0 deletions publish_firmware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import requests
from os.path import basename
from platformio import util

Import('env')

project_config = util.load_project_config()
bintray_config = {k: v for k, v in project_config.items("bintray")}
version = project_config.get("common", "version")

#
# Push new firmware to the Bintray storage using API
#


def publish_firmware(source, target, env):
firmware_path = str(source[0])
firmware_name = basename(firmware_path)

print("Uploading {0} to Bintray. Version: {1}".format(
firmware_name, version))

url = "/".join([
"https://api.bintray.com", "content",
bintray_config.get("user"),
bintray_config.get("repository"),
bintray_config.get("package"), version, firmware_name
])

headers = {
"Content-type": "application/octet-stream",
"X-Bintray-Publish": "1",
"X-Bintray-Override": "1"
}

r = requests.put(
url,
data=open(firmware_path, "rb"),
headers=headers,
auth=(bintray_config.get("user"), bintray_config['api_token']))

if r.status_code != 201:
print("Failed to submit package: {0}\n{1}".format(
r.status_code, r.text))
else:
print("The firmware has been successfuly published at Bintray.com!")


# Custom upload command and program name
env.Replace(
PROGNAME="firmware_v_%s" % version,
UPLOADCMD=publish_firmware
)

0 comments on commit 10f9f65

Please sign in to comment.