2 Commits
Author SHA1 Message Date
chriz d8ad7e7c2b Only output fimware file.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Successful in 7m47s
2026-10-27 22:17:05 +01:00
chriz ef7b6ac00a Do not publish the .elf and the partitions - only publish the fimware file. 2026-10-27 22:12:52 +01:00
+28 -43
View File
@@ -11,13 +11,6 @@ on:
permissions:
contents: write
env:
# PlatformIO environment to build (see environments.ini)
PIO_ENV: heltec-rtl_433
# Chip / flash layout used to create the merged (factory) image
ESP_CHIP: esp32
BOOTLOADER_OFFSET: '0x1000'
jobs:
build-and-release:
name: Build Firmware & Publish Gitea Release
@@ -43,16 +36,24 @@ jobs:
run: |
if ! python3 -m venv /tmp/pio-venv >/dev/null 2>&1; then
rm -rf /tmp/pio-venv
apt-get update && apt-get install -y python3 python3-venv python3-pip curl git
apt-get update && apt-get install -y python3 python3-venv python3-pip curl
python3 -m venv /tmp/pio-venv
fi
/tmp/pio-venv/bin/pip install --upgrade pip
/tmp/pio-venv/bin/pip install -U platformio setuptools
echo "/tmp/pio-venv/bin" >> "$GITHUB_PATH"
- name: Determine version
id: version
- name: Determine default environment and version
id: prep
run: |
# Only the first active "default_envs" entry from platformio.ini is built
PIO_ENV="$(sed -n 's/^[[:space:]]*default_envs[[:space:]]*=[[:space:]]*//p' platformio.ini \
| head -n 1 | cut -d',' -f1 | tr -d '[:space:]')"
if [ -z "${PIO_ENV}" ]; then
echo "No active default_envs found in platformio.ini" >&2
exit 1
fi
SHORT_SHA="${GITHUB_SHA::7}"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG_NAME="${GITHUB_REF_NAME}"
@@ -60,52 +61,41 @@ jobs:
BASE_VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo v1.7.0)"
TAG_NAME="${BASE_VERSION}-b${GITHUB_RUN_NUMBER}-${SHORT_SHA}"
fi
echo "Environment: ${PIO_ENV}, version: ${TAG_NAME}"
echo "pio_env=${PIO_ENV}" >> "$GITHUB_OUTPUT"
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
- name: Set version tag in sources
env:
TAG_NAME: ${{ steps.version.outputs.tag_name }}
TAG_NAME: ${{ steps.prep.outputs.tag_name }}
run: |
sed -i "s/version_tag/${TAG_NAME}/g" main/User_config.h scripts/latest_version.json
- name: Build OpenMQTTGateway Firmware (${{ env.PIO_ENV }})
- name: Build OpenMQTTGateway Firmware (${{ steps.prep.outputs.pio_env }})
env:
PIO_ENV: ${{ steps.prep.outputs.pio_env }}
run: |
mkdir -p ".pio/build/${PIO_ENV}"
pio run -e "${PIO_ENV}"
- name: Prepare Release Artifacts
env:
TAG_NAME: ${{ steps.version.outputs.tag_name }}
PIO_ENV: ${{ steps.prep.outputs.pio_env }}
TAG_NAME: ${{ steps.prep.outputs.tag_name }}
run: |
BUILD_DIR=".pio/build/${PIO_ENV}"
PREFIX="OpenMQTTGateway-${PIO_ENV}-${TAG_NAME}"
BOOT_APP0="${HOME}/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin"
mkdir -p dist
# OTA / update image
cp "${BUILD_DIR}/firmware.bin" dist/firmware.bin
cp "${BUILD_DIR}/firmware.bin" "dist/${PREFIX}-firmware.bin"
cp "${BUILD_DIR}/firmware.elf" "dist/${PREFIX}-firmware.elf"
cp "${BUILD_DIR}/partitions.bin" "dist/${PREFIX}-partitions.bin"
cp "${BUILD_DIR}/bootloader.bin" "dist/${PREFIX}-bootloader.bin"
cp "${BOOT_APP0}" "dist/${PREFIX}-boot_app0.bin"
# Merged factory image (flash at 0x0 on an erased chip)
pio pkg exec -p tool-esptoolpy -- esptool.py --chip "${ESP_CHIP}" merge_bin \
-o "dist/${PREFIX}-factory.bin" \
"${BOOTLOADER_OFFSET}" "${BUILD_DIR}/bootloader.bin" \
0x8000 "${BUILD_DIR}/partitions.bin" \
0xe000 "${BOOT_APP0}" \
0x10000 "${BUILD_DIR}/firmware.bin"
(cd dist && sha256sum * > SHA256SUMS.txt)
# Only the firmware image is published
cp ".pio/build/${PIO_ENV}/firmware.bin" "dist/OpenMQTTGateway-${PIO_ENV}-${TAG_NAME}.bin"
ls -lA dist
- name: Create Gitea Release and Upload Binaries
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.version.outputs.tag_name }}
SHORT_SHA: ${{ steps.version.outputs.short_sha }}
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 json
@@ -121,7 +111,6 @@ jobs:
sha = os.environ["GITHUB_SHA"]
short_sha = os.environ["SHORT_SHA"]
pio_env = os.environ["PIO_ENV"]
bootloader_offset = os.environ["BOOTLOADER_OFFSET"]
api_base = f"{server_url}/api/v1/repos/{repo}"
headers = {
@@ -134,10 +123,7 @@ jobs:
f"Automated OpenMQTTGateway firmware build.\n\n"
f"- **Environment:** `{pio_env}`\n"
f"- **Commit:** `{short_sha}`\n"
f"- **OTA update:** Upload `firmware.bin` via the WebUI / OTA.\n"
f"- **Fresh install:** Flash `*-factory.bin` at offset `0x0`, or flash "
f"`*-bootloader.bin` @ `{bootloader_offset}`, `*-partitions.bin` @ `0x8000`, "
f"`*-boot_app0.bin` @ `0xe000` and `*-firmware.bin` @ `0x10000`."
f"- **OTA update:** Upload the `.bin` file via the WebUI / OTA."
)
# Check if a release for this tag already exists
@@ -162,7 +148,7 @@ jobs:
"name": f"OpenMQTTGateway {tag_name} ({pio_env})",
"body": release_notes,
"draft": False,
"prerelease": os.environ.get("GITHUB_REF_TYPE") != "tag",
"prerelease": False,
}).encode("utf-8")
req = urllib.request.Request(f"{api_base}/releases", data=payload, headers=headers, method="POST")
with urllib.request.urlopen(req) as resp:
@@ -189,4 +175,3 @@ jobs:
], check=True)
print(f"Uploaded {filename} successfully.")
EOF