4 Commits
Author SHA1 Message Date
chriz 02a8732318 Fix build action.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Successful in 15m16s
2026-10-29 21:42:09 +01:00
chriz b1e2301ea1 Release package as part of build action.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Failing after 8m2s
2026-10-29 20:53:36 +01:00
chriz 0d8a8b35f0 disable some decoders.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Canceled after 3m53s
2026-10-29 20:49:24 +01:00
chriz d686cf71fc enable oled.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Successful in 15m42s
2026-10-29 18:58:25 +01:00
3 changed files with 119 additions and 30 deletions

No files matched your search

+38 -6
View File
@@ -10,6 +10,7 @@ on:
permissions:
contents: write
packages: write
jobs:
build-and-release:
@@ -58,7 +59,7 @@ jobs:
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG_NAME="${GITHUB_REF_NAME}"
else
BASE_VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo v1.7.0)"
BASE_VERSION="$(git describe --tags --abbrev=0 --exclude '*-b*' 2>/dev/null || echo v1.7.0)"
TAG_NAME="${BASE_VERSION}-b${GITHUB_RUN_NUMBER}-${SHORT_SHA}"
fi
@@ -87,14 +88,16 @@ jobs:
cp ".pio/build/${PIO_ENV}/firmware.bin" "dist/OpenMQTTGateway-${PIO_ENV}-${TAG_NAME}.bin"
ls -lA dist
- name: Create Gitea Release and Upload Binaries
- name: Create Gitea Release and Publish Package
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEA_PKG_TOKEN: ${{ secrets.GITEATOKEN }}
PIO_ENV: ${{ steps.prep.outputs.pio_env }}
TAG_NAME: ${{ steps.prep.outputs.tag_name }}
SHORT_SHA: ${{ steps.prep.outputs.short_sha }}
run: |
python3 - << 'EOF'
import base64
import json
import os
import subprocess
@@ -103,7 +106,10 @@ jobs:
server_url = os.environ["GITHUB_SERVER_URL"].rstrip("/")
repo = os.environ["GITHUB_REPOSITORY"]
owner, repo_name = repo.split("/", 1)
actor = os.environ.get("GITHUB_ACTOR") or owner
token = os.environ["GITEA_TOKEN"]
pkg_token = os.environ.get("GITEA_PKG_TOKEN") or token
tag_name = os.environ["TAG_NAME"]
sha = os.environ["GITHUB_SHA"]
short_sha = os.environ["SHORT_SHA"]
@@ -153,7 +159,12 @@ jobs:
release_id = data["id"]
print(f"Created release ID {release_id} for tag {tag_name}")
# Upload firmware binaries in dist/
# Upload firmware binary to Release and Gitea Package Registry
# Note: Gitea's Generic Package Registry upload router is at /api/packages/ (not /api/v1/packages/)
package_name = f"{repo_name}-{pio_env}"
pkg_base = f"{server_url}/api/packages/{owner}/generic/{package_name}/{tag_name}"
basic_auth = base64.b64encode(f"{actor}:{pkg_token}".encode("utf-8")).decode("ascii")
for filename in sorted(os.listdir("dist")):
if filename in existing_assets:
del_req = urllib.request.Request(
@@ -163,12 +174,33 @@ jobs:
)
urllib.request.urlopen(del_req).close()
filepath = os.path.join("dist", filename)
print(f"Uploading {filename}...")
print(f"Uploading {filename} to Release...")
subprocess.run([
"curl", "--fail", "-sS", "-X", "POST",
"curl", "--fail", "-sS", "-o", "/dev/null", "-X", "POST",
"-H", f"Authorization: token {token}",
"-F", f"attachment=@{filepath}",
f"{api_base}/releases/{release_id}/assets?name={filename}"
], check=True)
print(f"Uploaded {filename} successfully.")
print(f"Uploaded {filename} to Release successfully.")
# Publish to Gitea Generic Package Registry (delete existing file first if re-running)
pkg_file_url = f"{pkg_base}/{filename}"
try:
del_pkg_req = urllib.request.Request(
pkg_file_url,
headers={"Authorization": f"Basic {basic_auth}"},
method="DELETE",
)
urllib.request.urlopen(del_pkg_req).close()
except urllib.error.HTTPError as e:
if e.code != 404:
raise
print(f"Publishing {filename} to Gitea Package {package_name}/{tag_name}...")
subprocess.run([
"curl", "--fail", "-sS", "-o", "/dev/null", "-X", "PUT",
"--user", f"{actor}:{pkg_token}",
"--upload-file", filepath,
pkg_file_url,
], check=True)
print(f"Published {filename} to Gitea Package Registry successfully.")
EOF
+17 -3
View File
@@ -1041,12 +1041,13 @@ build_flags =
'-DZgatewayRTL_433="rtl_433"'
'-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
; '-DZdisplaySSD1306="HELTEC_SSD1306"'
'-DZdisplaySSD1306="HELTEC_SSD1306"'
; '-DLOG_TO_OLED=false' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=true'
; '-DDISPLAY_BRIGHTNESS=20'
'-DJSON_TO_OLED=true'
'-DDISPLAY_IDLE_LOGO=true'
'-DDISPLAY_BRIGHTNESS=20'
; '-DDISPLAY_METRIC=false'
custom_description = Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 HELTEC LORA32 V2
@@ -1056,6 +1057,19 @@ extra_scripts =
${env.extra_scripts}
scripts/enable_rtl433_decoders.py
custom_rtl_433_enable_decoders = esa_energy
custom_rtl_433_disable_decoders =
skylink_motion
acurite_rain_896
acurite_th
acurite_txr
acurite_986
acurite_606
acurite_00275rm
acurite_590tx
acurite_01185m
rainpoint
rainpoint_hcs012arf
wec2103
[env:heltec-rtl_433-fsk]
platform = ${com.esp32_platform}
+64 -21
View File
@@ -1,7 +1,7 @@
# Re-enable rtl_433_ESP decoders that are disabled by default in the library.
# Configure rtl_433_ESP decoders (enable or disable specific protocols).
#
# Newer rtl_433_ESP releases mark some decoders with `.disabled = 1` (e.g.
# `esa_energy` since v0.6.x) and there is no build flag to turn them back on.
# `esa_energy` since v0.6.x) and enable many noisy OOK decoders by default.
# This script patches the decoder definitions inside the downloaded library in
# .pio/libdeps/<env>/ before compilation.
#
@@ -10,6 +10,9 @@
# ${env.extra_scripts}
# scripts/enable_rtl433_decoders.py
# custom_rtl_433_enable_decoders = esa_energy
# custom_rtl_433_disable_decoders =
# skylink_motion
# acurite_rain_896
#
# Must run as a normal (post) script: lib_deps are installed while the platform
# builder script runs, so a "pre:" script would not find the library on a clean
@@ -22,23 +25,23 @@ import re
Import("env")
def enable_decoders(libdeps_dir, decoders):
"""Patch `.disabled = N` to `.disabled = 0` for the given r_device names.
Returns a dict decoder -> status ("enabled", "already enabled", "not found").
"""
def patch_decoders(libdeps_dir, enable_decoders, disable_decoders):
"""Patch `.disabled` for the given r_device names in rtl_433_ESP."""
device_files = glob.glob(
os.path.join(libdeps_dir, "**", "src", "rtl_433", "devices", "*.c"),
recursive=True,
)
result = {name: "not found" for name in decoders}
enable_status = {name: "not found" for name in enable_decoders}
disable_status = {name: "not found" for name in disable_decoders}
for path in device_files:
with open(path, "r", encoding="utf-8", newline="") as f:
content = f.read()
changed = False
for name in decoders:
for name in enable_decoders:
block_re = re.compile(
r"(r_device\s+const\s+" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
r"(r_device\s+(?:const\s+)?" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
re.DOTALL,
)
match = block_re.search(content)
@@ -49,25 +52,65 @@ def enable_decoders(libdeps_dir, decoders):
r"(\.disabled\s*=\s*)[1-9]\d*", r"\g<1>0", body
)
if count:
content = content[: match.start(2)] + new_body + content[match.end(2):]
content = content[: match.start(2)] + new_body + content[match.end(2) :]
changed = True
result[name] = "enabled"
enable_status[name] = "enabled"
else:
result[name] = "already enabled"
enable_status[name] = "already enabled"
for name in disable_decoders:
block_re = re.compile(
r"(r_device\s+(?:const\s+)?" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
re.DOTALL,
)
match = block_re.search(content)
if not match:
continue
body = match.group(2)
if re.search(r"\.disabled\s*=\s*[1-9]\d*", body):
disable_status[name] = "already disabled"
continue
if re.search(r"\.disabled\s*=\s*0\b", body):
new_body = re.sub(r"(\.disabled\s*=\s*)0\b", r"\g<1>1", body)
else:
nl = "\r\n" if "\r\n" in body else "\n"
new_body, count = re.subn(
r"([ \t]*\.fields\s*=)",
r" .disabled = 1," + nl + r"\g<1>",
body,
count=1,
)
if not count:
new_body = body + " .disabled = 1," + nl
content = content[: match.start(2)] + new_body + content[match.end(2) :]
changed = True
disable_status[name] = "disabled"
if changed:
with open(path, "w", encoding="utf-8", newline="") as f:
f.write(content)
return result
return enable_status, disable_status
decoders = env.GetProjectOption("custom_rtl_433_enable_decoders", "").split()
if decoders:
enable_list = env.GetProjectOption("custom_rtl_433_enable_decoders", "").split()
disable_list = env.GetProjectOption("custom_rtl_433_disable_decoders", "").split()
if enable_list or disable_list:
libdeps_dir = os.path.join(env.subst("$PROJECT_LIBDEPS_DIR"), env.subst("$PIOENV"))
status = enable_decoders(libdeps_dir, decoders)
for name, state in status.items():
enable_status, disable_status = patch_decoders(libdeps_dir, enable_list, disable_list)
for name, state in enable_status.items():
print("rtl_433_ESP decoder %s: %s" % (name, state))
missing = [name for name, state in status.items() if state == "not found"]
for name, state in disable_status.items():
print("rtl_433_ESP decoder %s: %s" % (name, state))
missing = [
name
for name, state in list(enable_status.items()) + list(disable_status.items())
if state == "not found"
]
if missing:
print("Error: rtl_433_ESP decoder(s) not found in %s: %s" % (libdeps_dir, ", ".join(missing)))
print(
"Error: rtl_433_ESP decoder(s) not found in %s: %s"
% (libdeps_dir, ", ".join(missing))
)
env.Exit(1)