Skip to content

Commit

Permalink
Workflow fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
morgendagen committed Jan 20, 2024
1 parent 4f05c5f commit 960ea6e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
PLATFORMIO_BUILD_FLAGS: -D SPECIFIC_MACRO -I/extra/inc
VERSION: ${{ steps.get_version.outputs.version-without-v }}

- name: Archive production artifacts
uses: actions/upload-artifact@v2
- name: Release
uses: softprops/action-gh-release@v1
with:
name: firmware
path: .pio/build/**/firmware_*.bin
files: |
.pio/build/*/firmware_*.bin
.pio/build/*/firmware_*.bin.gz
2 changes: 2 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ the safe UART baudrate to 38400 bps.
To test the release workflow execute:

$ act --container-architecture linux/amd64 --artifact-server-path $PWD/act-cache -e act/release.json -W .github/workflows/release.yaml

Note that the `Release` step will fail.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build_flags =
extra_scripts =
${env.extra_scripts}
pre:scripts/get_build_time.py
scripts/make_gz.py
upload_port =
upload_resetmethod = nodemcu
upload_speed = 115200
Expand Down
23 changes: 23 additions & 0 deletions scripts/make_gz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import gzip
import shutil
import os
Import("env")


def compress_firmware(source, target, env):
""" Compress ESP8266 firmware using gzip for 'compressed OTA upload' """
SOURCE_FILE = env.subst("$BUILD_DIR") + os.sep + env.subst("$PROGNAME") + ".bin"
if not os.path.exists(SOURCE_FILE+'.bak'):
print("Compressing firmware for upload...")
shutil.move(SOURCE_FILE, SOURCE_FILE + '.bak')
with open(SOURCE_FILE + '.bak', 'rb') as f_in:
with gzip.open(SOURCE_FILE + '.gz', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
shutil.move(SOURCE_FILE + '.bak', SOURCE_FILE)

ORG_FIRMWARE_SIZE = os.stat(SOURCE_FILE).st_size
GZ_FIRMWARE_SIZE = os.stat(SOURCE_FILE + '.gz').st_size

print("Compression reduced firmware size to {:.0f}% of original (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [compress_firmware])

0 comments on commit 960ea6e

Please sign in to comment.