diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6314ac6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +# This is a basic workflow to help you get started with Actions + +name: createRelease + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ release ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + release: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + #set version + - name: set version + id: version + run: echo "::set-output name=version::$(date +'%Y%m%d')" + - name: Install deps + run: | + #apt-get update + #apt-get install -y python3-pip nodejs + python3 -m pip install --upgrade pip + pip install -U platformio + # Runs a single command using the runners shell + - name: build package + env: + VERSION: ${{ steps.version.outputs.version}} + PLATFORMIO_BUILD_FLAGS: "-DGWRELEASEVERSION=${{ steps.version.outputs.version}}" + run: pio run + + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.version}} + release_name: ${{ steps.version.outputs.version }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PKG_NAME: m5stack-atom + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./pio/build/${{ env.PKG_NAME }}/${{ env.PKG_NAME }}-all.bin + asset_name: ${{ env.PKG_NAME }}-all.bin + asset_content_type: application/octet-stream diff --git a/extra_script.py b/extra_script.py index e1c979e..df4d6b5 100644 --- a/extra_script.py +++ b/extra_script.py @@ -5,6 +5,8 @@ import os import sys import inspect import json +from datetime import datetime +Import("env") GEN_DIR='generated' CFG_FILE='web/config.json' FILES=['web/index.html',CFG_FILE,'web/index.js','web/index.css'] @@ -80,4 +82,6 @@ if not checkDir(): for f in FILES: print("compressing %s"%f) compressFile(f) -generateCfg() \ No newline at end of file +generateCfg() +version=datetime.now().strftime("%Y%m%d-%H%M") +env.Append(CPPDEFINES=[('GWDEVVERSION',version)]) \ No newline at end of file diff --git a/partitions_custom.csv b/partitions_custom.csv new file mode 100644 index 0000000..17b631d --- /dev/null +++ b/partitions_custom.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x140000, +app1, app, ota_1, 0x150000,0x130000, +nvs, data, nvs, 0x280000, 0x10000, +spiffs, data, spiffs, 0x290000,0x170000, \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 1b71302..2e5cadf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,7 +23,10 @@ board_build.embed_files = generated/index.js.gz generated/index.css.gz generated/config.json.gz -extra_scripts = pre:extra_script.py +board_build.partitions = partitions_custom.csv +extra_scripts = + pre:extra_script.py + post:post.py build_flags = -Igenerated [env:m5stack-atom] diff --git a/post.py b/post.py new file mode 100644 index 0000000..6fae19a --- /dev/null +++ b/post.py @@ -0,0 +1,35 @@ +Import("env", "projenv") +import os + +print("##post script running") + +def post(source,target,env): + #print(env.Dump()) + esptool=env.get('UPLOADER') + uploaderflags=env.subst("${UPLOADERFLAGS}") + base=env.subst("$PIOENV") + appoffset=env.subst("$ESP32_APP_OFFSET") + firmware=env.subst("$BUILD_DIR/${PROGNAME}.bin") + python=env.subst("$PYTHONEXE") + print("base=%s,esptool=%s,appoffset=%s,uploaderflags=%s"%(base,esptool,appoffset,uploaderflags)) + uploadparts=uploaderflags.split(" ") + #currently hardcoded last 8 parameters... + if len(uploadparts) < 6: + print("uploaderflags does not have enough parameter") + return + uploadfiles=uploadparts[-6:] + for i in range(1,len(uploadfiles),2): + if not os.path.isfile(uploadfiles[i]): + print("file %s for combine not found"%uploadfiles[i]) + return + offset=uploadfiles[0] + outfile=os.path.join(env.subst("$BUILD_DIR"),base+"-all.bin") + cmd=[python,esptool,"--chip","esp32","merge_bin","--target-offset",offset,"-o",outfile] + cmd+=uploadfiles + cmd+=[appoffset,firmware] + print("running %s"%" ".join(cmd)) + env.Execute(" ".join(cmd),"#testpost") +env.AddPostAction( + "$BUILD_DIR/${PROGNAME}.bin", + post +) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 63d2afa..c0d22f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#define VERSION "0.6.4" +#define GWSTR(x) #x +#ifdef GWRELEASEVERSION +#define VERSION GWSTR(GWRELEASEVERSION) +#define LOGLEVEL GwLog::ERROR +#elif GWDEVVERSION +#define VERSION GWSTR(GWDEVVERSION) +#define LOGLEVEL GwLog::DEBUG +#else +#define VERSION "0.7.0" +#define LOGLEVEL GwLog::DEBUG +#endif // #define GW_MESSAGE_DEBUG_ENABLED // #define FALLBACK_SERIAL @@ -61,7 +71,7 @@ const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting typedef std::map StringMap; -GwLog logger(GwLog::DEBUG,NULL); +GwLog logger(LOGLEVEL,NULL); GwConfigHandler config(&logger); #ifdef GWBUTTON_PIN bool fixedApPass=false;