diff --git a/.github/workflows/build_esp32_dev_firmware.yml b/.github/workflows/build_esp32_dev_firmware.yml deleted file mode 100644 index c00640fa1..000000000 --- a/.github/workflows/build_esp32_dev_firmware.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Build ESP32 Dev Firmware - -on: - push: - branches: - - esp32_dev - tags: - # - '*.*.*' - paths: - - 'CHANGELOG_LATEST.md' - workflow_dispatch: - branches: [ esp32_dev ] - -jobs: - - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Version - id: fetch_version - run: | - version=`grep -E '^#define EMSESP_APP_VERSION' ./src/version.h | awk '{print $3}' | sed 's/"//g'` - echo "::set-output name=s::$version" - - - name: Setup Python - uses: actions/setup-python@v1 - - - name: Install - run: | - python -m pip install --upgrade pip - pip install -U platformio - platformio upgrade - platformio update - - - name: Build web - run: | - cd interface - npm install - npm run build - - - name: Build images - run: | - platformio run -e esp32-ci - - - name: Delete - uses: dev-drprasad/delete-tag-and-release@v0.1.2 - # if: startsWith(github.ref, 'refs/tags/') - with: - delete_release: true - tag_name: esp32_dev - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Changelog - run: cat RELEASENOTES_DEV.md CHANGELOG_LATEST.md > BODY.txt - - - name: Release - uses: softprops/action-gh-release@v1 - # if: startsWith(github.ref, 'refs/tags/') - with: - body_path: BODY.txt - name: ESP32 Development Build v${{steps.fetch_version.outputs.s}} - tag_name: esp32_dev - prerelease: true - files: | - ./build/firmware/*.* - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/.github/workflows/pre_release.yml b/.github/workflows/pre_release.yml new file mode 100644 index 000000000..b45a099f4 --- /dev/null +++ b/.github/workflows/pre_release.yml @@ -0,0 +1,59 @@ +name: "pre-release" + +on: + push: + branches: + - "dev" + +jobs: + pre-release: + + name: "Automatic pre-release build" + runs-on: ubuntu-latest + + steps: + + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Get build variables + id: build_info + run: | + version=`grep -E '^#define EMSESP_APP_VERSION' ./src/version.h | awk -F'"' '{print $2}'` + echo "::set-output name=version::$version" + platform=`grep -E '^#define EMSESP_PLATFORM' ./src/version.h | awk -F'"' '{print $2}'` + echo "::set-output name=platform::$platform" + + - name: Compile locally + run: make + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Install pio + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade + platformio update + + - name: Build web + run: | + cd interface + npm install + npm run build + + - name: Build firmware + run: | + platformio run -e ci + + - name: Release + id: "automatic_releases" + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + title: ${{steps.build_info.outputs.platform}} Development Build v${{steps.build_info.outputs.version}} + automatic_release_tag: "latest" + prerelease: true + files: | + CHANGELOG_DEV.md diff --git a/.github/workflows/release_esp32_stable.yml b/.github/workflows/release_esp32_stable.yml deleted file mode 100644 index 0e446e295..000000000 --- a/.github/workflows/release_esp32_stable.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Release Stable ESP32 - -on: - workflow_dispatch: - branches: [ stable_esp32 ] - -jobs: - - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Version - id: fetch_version - run: | - version=`grep -E '^#define EMSESP_APP_VERSION' ./src/version.h | awk '{print $3}' | sed 's/"//g'` - echo "::set-output name=s::$version" - - - name: Setup Python - uses: actions/setup-python@v1 - - - name: Install - run: | - python -m pip install --upgrade pip - pip install -U platformio - platformio upgrade - platformio update - - - name: Build web - run: | - cd interface - npm install - npm run build - - - name: Build images - run: | - platformio run -e esp32-ci - - - name: Changelog - run: cat RELEASENOTES.md CHANGELOG_LATEST.md > BODY.txt - - - name: Release - uses: softprops/action-gh-release@v1 - with: - body_path: BODY.txt - name: EMS-ESP v${{steps.fetch_version.outputs.s}} (ESP32) - tag_name: v${{steps.fetch_version.outputs.s}} - prerelease: false - files: | - ./build/firmware/*.* - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - \ No newline at end of file diff --git a/.github/workflows/standalone_build.yml b/.github/workflows/standalone_build.yml deleted file mode 100644 index 315963069..000000000 --- a/.github/workflows/standalone_build.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Standalone Build - -on: - push: - branches: [ esp32_dev ] - paths: - - 'src/**' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: make clean - run: make clean - - - name: make - run: make - \ No newline at end of file diff --git a/.github/workflows/tagged_release.yml b/.github/workflows/tagged_release.yml new file mode 100644 index 000000000..e8287d26e --- /dev/null +++ b/.github/workflows/tagged_release.yml @@ -0,0 +1,56 @@ +name: "tagged-release" + +on: + push: + tags: + - "v*" + +jobs: + tagged-release: + + name: "Tagged Release" + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Get build variables + id: build_info + run: | + version=`grep -E '^#define EMSESP_APP_VERSION' ./src/version.h | awk -F'"' '{print $2}'` + echo "::set-output name=version::$version" + platform=`grep -E '^#define EMSESP_PLATFORM' ./src/version.h | awk -F'"' '{print $2}'` + echo "::set-output name=platform::$platform" + + - name: Compile locally + run: make + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Install pio + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade + platformio update + + - name: Build web + run: | + cd interface + npm install + npm run build + + - name: Build firmware + run: | + platformio run -e ci + + - name: Release + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + CHANGELOG.md + ./build/firmware/*.* diff --git a/platformio.ini b/platformio.ini index 882bdb97c..3a578d98c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -61,7 +61,7 @@ check_flags = clangtidy: --checks=-*,clang-analyzer-*,performance-* ; build for GitHub Actions CI -[env:esp32-ci] +[env:ci] extra_scripts = scripts/rename_fw.py board = esp32dev diff --git a/scripts/rename_fw.py b/scripts/rename_fw.py index 17075b913..70f299989 100644 --- a/scripts/rename_fw.py +++ b/scripts/rename_fw.py @@ -1,16 +1,18 @@ -Import('env', "projenv") +Import("env") import os import re import shutil -import gzip OUTPUT_DIR = "build{}".format(os.path.sep) def bin_copy(source, target, env): - # get the EMS-ESP version + # get the build info bag = {} - exprs = [(re.compile(r'^#define EMSESP_APP_VERSION\s+"(\S+)"'), 'app_version')] + exprs = [ + (re.compile(r'^#define EMSESP_APP_VERSION\s+"(\S+)"'), 'app_version'), + (re.compile(r'^#define EMSESP_PLATFORM\s+"(\S+)"'), 'platform'), + ] with open('./src/version.h', 'r') as f: for l in f.readlines(): for expr, var in exprs: @@ -18,33 +20,43 @@ def bin_copy(source, target, env): if m and len(m.groups()) > 0: bag[var] = m.group(1) - # esp8266 or esp32 - platform = "esp" + env['PIOPLATFORM'].strip("espressif") + app_version = bag.get('app_version') + platform = bag.get("platform") - # if using the pio build directory, use str(target[0]).split(os.path.sep)[2] - variant = "EMS-ESP-" + bag.get('app_version').replace(".", "_") + "-" + platform + # print(env.Dump()) + # my_flags = env.ParseFlags(env['BUILD_FLAGS']) + # defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")} + # print(my_flags) + # print((my_flags.get("CPPDEFINES")) + + # alternatively take platfrom from the pio target + # platform = str(target[0]).split(os.path.sep)[2] + + print("app version: "+app_version) + print("platform: "+platform) + + # convert . to _ so Windows doesn't complain + variant = "EMS-ESP-" + app_version.replace(".", "_") + "-" + platform - # create string with location and file names based on variant - bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant) - gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant) - - # check if firmware directory and target subdirectories (esp8266/esp32) exist and create if necessary + # check if output directories exist and create if necessary if not os.path.isdir(OUTPUT_DIR): os.mkdir(OUTPUT_DIR) + for d in ['firmware']: if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)): os.mkdir("{}{}".format(OUTPUT_DIR, d)) - # copy firmware.bin to new name and in the build/firmware folder, delete if already exists - if os.path.isfile(bin_file): os.remove(bin_file) + # create string with location and file names based on variant + bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant) + + # check if new target files exist and remove if necessary + for f in [bin_file]: + if os.path.isfile(f): + os.remove(f) + + print("renaming file to "+bin_file) + + # copy firmware.bin to firmware/.bin shutil.copy(str(target[0]), bin_file) - # create the gzip'd version - if os.path.isfile(gzip_file): os.remove(gzip_file) - with open(bin_file, "rb") as fp: - with gzip.open(gzip_file, "wb", compresslevel = 9) as f: - shutil.copyfileobj(fp, f) - - print("Built firmwares: "+ bin_file + ", " + gzip_file) - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_copy]) diff --git a/src/version.h b/src/version.h index c266689bc..ae3f99ef3 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1,2 @@ -#define EMSESP_APP_VERSION "3.0.0b7" +#define EMSESP_APP_VERSION "3.0.0" +#define EMSESP_PLATFORM "ESP32" \ No newline at end of file