2 Commits
Author SHA1 Message Date
chriz 29a7f74e97 Gitea actions.
Build and Release OpenMQTTGateway Firmware / Build Firmware & Publish Gitea Release (push) Successful in 8m18s
2026-10-27 22:05:34 +01:00
chriz 523bc584fd Gitea build action. 2026-10-27 21:59:17 +01:00
7 changed files with 192 additions and 326 deletions

No files matched your search

+192
View File
@@ -0,0 +1,192 @@
name: Build and Release OpenMQTTGateway Firmware
on:
push:
branches:
- development
tags:
- '*'
workflow_dispatch:
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
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache PlatformIO packages
uses: actions/cache@v4
with:
path: |
~/.platformio
.pio/libdeps
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini', 'environments.ini') }}
restore-keys: |
${{ runner.os }}-pio-
- name: Install Python & PlatformIO
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
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
run: |
SHORT_SHA="${GITHUB_SHA::7}"
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)"
TAG_NAME="${BASE_VERSION}-b${GITHUB_RUN_NUMBER}-${SHORT_SHA}"
fi
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 }}
run: |
sed -i "s/version_tag/${TAG_NAME}/g" main/User_config.h scripts/latest_version.json
- name: Build OpenMQTTGateway Firmware (${{ env.PIO_ENV }})
run: |
pio run -e "${PIO_ENV}"
- name: Prepare Release Artifacts
env:
TAG_NAME: ${{ steps.version.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)
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 }}
run: |
python3 - << 'EOF'
import json
import os
import subprocess
import urllib.request
import urllib.error
server_url = os.environ["GITHUB_SERVER_URL"].rstrip("/")
repo = os.environ["GITHUB_REPOSITORY"]
token = os.environ["GITEA_TOKEN"]
tag_name = os.environ["TAG_NAME"]
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 = {
"Authorization": f"token {token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
release_notes = (
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`."
)
# Check if a release for this tag already exists
release_id = None
existing_assets = {}
req = urllib.request.Request(f"{api_base}/releases/tags/{tag_name}", headers=headers)
try:
with urllib.request.urlopen(req) as resp:
data = json.loads(resp.read().decode("utf-8"))
release_id = data["id"]
existing_assets = {a["name"]: a["id"] for a in data.get("assets", [])}
print(f"Found existing release ID {release_id} for tag {tag_name}")
except urllib.error.HTTPError as e:
if e.code != 404:
raise
# Create a new release if none exists
if release_id is None:
payload = json.dumps({
"tag_name": tag_name,
"target_commitish": sha,
"name": f"OpenMQTTGateway {tag_name} ({pio_env})",
"body": release_notes,
"draft": False,
"prerelease": os.environ.get("GITHUB_REF_TYPE") != "tag",
}).encode("utf-8")
req = urllib.request.Request(f"{api_base}/releases", data=payload, headers=headers, method="POST")
with urllib.request.urlopen(req) as resp:
data = json.loads(resp.read().decode("utf-8"))
release_id = data["id"]
print(f"Created release ID {release_id} for tag {tag_name}")
# Upload firmware binaries in dist/
for filename in sorted(os.listdir("dist")):
if filename in existing_assets:
del_req = urllib.request.Request(
f"{api_base}/releases/{release_id}/assets/{existing_assets[filename]}",
headers=headers,
method="DELETE",
)
urllib.request.urlopen(del_req).close()
filepath = os.path.join("dist", filename)
print(f"Uploading {filename}...")
subprocess.run([
"curl", "--fail", "-sS", "-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.")
EOF
-128
View File
@@ -1,128 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
build:
strategy:
fail-fast: false
matrix:
environments:
- "rfbridge"
- "rfbridge-direct"
- "esp32dev-all-test"
- "esp32dev-rf"
- "esp32dev-pilight-cc1101"
- "esp32dev-somfy-cc1101"
- "esp32dev-pilight-somfy-cc1101"
- "esp32dev-weatherstation"
- "esp32dev-gf-sun-inverter"
- "esp32dev-ir"
- "esp32dev-ble"
- "esp32dev-ble-mqtt-undecoded"
- "esp32dev-ble-aws"
- "esp32feather-ble"
- "esp32-lolin32lite-ble"
- "esp32-olimex-gtw-ble-eth"
- "esp32-olimex-gtw-ble-poe"
- "esp32-olimex-gtw-ble-poe-iso"
- "esp32-wt32-eth01-ble-eth"
- "esp32-olimex-gtw-ble-wifi"
- "esp32-m5stick-ble"
- "esp32-m5stack-ble"
- "esp32-m5tough-ble"
- "esp32-m5stick-c-ble"
- "esp32-m5stick-cp-ble"
- "esp32s3-atomS3U"
- "esp32-m5atom-matrix"
- "esp32-m5atom-lite"
- "esp32dev-rtl_433"
- "esp32doitv1-aithinker-r01-sx1278"
- "heltec-rtl_433"
- "heltec-rtl_433-fsk"
- "heltec-ble"
- "lilygo-rtl_433"
- "lilygo-rtl_433-fsk"
- "lilygo-ble"
- "esp32dev-multi_receiver"
- "esp32dev-multi_receiver-pilight"
- "tinypico-ble"
- "ttgo-lora32-v1"
- "ttgo-lora32-v21"
- "ttgo-t-beam"
- "heltec-wifi-lora-32"
- "shelly-plus1"
- "nodemcuv2-all-test"
- "nodemcuv2-fastled-test"
- "nodemcuv2-2g"
- "nodemcuv2-ir"
- "nodemcuv2-rs232"
- "avatto-bakeey-ir"
- "nodemcuv2-rf"
- "nodemcuv2-rf-cc1101"
- "nodemcuv2-somfy-cc1101"
- "manual-wifi-test"
- "nodemcuv2-mqtt-fw-test"
- "rf-wifi-gateway"
- "nodemcuv2-rf2"
- "nodemcuv2-rf2-cc1101"
- "nodemcuv2-pilight"
- "nodemcuv2-weatherstation"
- "sonoff-basic"
- "sonoff-basic-rfr3"
- "atmega-all-test"
- "uno-rf"
- "uno-fastled"
- "esp32dev-ble-datatest"
- "esp32s3-dev-c1-ble"
- "esp32c3-dev-m1-ble"
- "airm2m_core_esp32c3"
- "esp32c3_lolin_mini"
- "esp32c3-m5stamp"
- "thingpulse-espgateway"
- "theengs-bridge"
- "esp32dev-ble-idf"
runs-on: ubuntu-latest
name: Build with PlatformIO
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install platformio
run: |
python -m pip install --upgrade pip
pip install platformio
pip install setuptools
- name: Extract ESP32 platform version from platformio.ini
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Run PlatformIO
run: platformio run -e ${{ matrix.environments }}
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.environments }}
path: |
.pio/build/*/firmware.bin
.pio/build/*/partitions.bin
retention-days: 7
documentation:
runs-on: ubuntu-latest
name: Create the documentation
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: Download Common Config
run: |
curl -o docs/.vuepress/public/commonConfig.js https://www.theengs.io/commonConfig.js
- name: Install build dependencies
run: npm install
- name: Build documentation
run: npm run docs:build
@@ -1,67 +0,0 @@
name: Build binaries, docs and publish to dev folder
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build-upload:
runs-on: ubuntu-latest
if: github.repository_owner == '1technophile'
name: Build and upload Assets to Release
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/short-sha@v2.1
id: short-sha
with:
length: 6
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install platformio requests shutils
npm install
- name: Set sha tag
run: |
sed -i "s/version_tag/${{ steps.short-sha.outputs.sha }}/g" main/User_config.h scripts/latest_version_dev.json
sed -i "s/version_tag/DEVELOPMENT SHA:${{ steps.short-sha.outputs.sha }} TEST ONLY/g" docs/.vuepress/config.js
sed -i "s|base: '/'|base: '/dev/'|g" docs/.vuepress/config.js
- name: Extract ESP32 platform version from platformio.ini
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Run PlatformIO
run: |
export PLATFORMIO_BUILD_FLAGS="'-DDEVELOPMENTOTA=true'"
platformio run
- name: Prepare Release Assets
run: |
sudo apt install rename
./scripts/prepare_deploy.sh
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: Download Common Config
run: |
curl -o docs/.vuepress/public/commonConfig.js https://www.theengs.io/commonConfig.js
- name: Build documentation
run: |
python ./scripts/gen_wu.py --dev
npm run docs:build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/.vuepress/dist
destination_dir: dev
cname: docs.openmqttgateway.com
- name: Running Page Speed Insights
uses: jakepartusch/psi-action@v1.3
id: psi
with:
url: "https://docs.openmqttgateway.com/dev/"
threshold: 70
key: ${{ secrets.APIKEY }}
-16
View File
@@ -1,16 +0,0 @@
name: Check Code Format
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check main format
uses: DoozyX/clang-format-lint-action@v0.6
with:
source: "./main"
extensions: "h,ino"
clangFormatVersion: 9
-45
View File
@@ -1,45 +0,0 @@
name: Create and publish documentation
on:
workflow_dispatch:
workflow_call:
jobs:
documentation:
runs-on: ubuntu-latest
name: Create the documentation and deploy it to GitHub Pages
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install requests pandas markdown pytablereader tabulate
npm install
- name: Download Common Config
run: |
curl -o docs/.vuepress/public/commonConfig.js https://www.theengs.io/commonConfig.js
- name: get lastest release tag
id: last_release
uses: InsonusK/get-latest-release@v1.0.1
with:
myToken: ${{ github.token }}
view_top: 1
- name: Set version tag from git
run: sed -i "s/version_tag/${{steps.last_release.outputs.tag_name}}/g" docs/.vuepress/config.js scripts/latest_version.json
- name: Build documentation
run: |
python ./scripts/generate_board_docs.py
python ./scripts/gen_wu.py ${GITHUB_REPOSITORY}
npm run docs:build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/.vuepress/dist
cname: docs.openmqttgateway.com
-47
View File
@@ -1,47 +0,0 @@
name: Release
on:
release:
types: [published]
jobs:
build-upload:
runs-on: ubuntu-latest
name: Build and upload Assets to Release
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install platformio
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Set version tag from git
run: sed -i "s/version_tag/${GITHUB_REF#refs/tags/}/g" main/User_config.h scripts/latest_version.json
- name: Extract ESP32 platform version from platformio.ini
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Run PlatformIO
run: platformio run
- name: Prepare Release Assets
run: |
sudo apt install rename
./scripts/prepare_deploy.sh
- name: Get upload url
id: release-id
run: |
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)
echo "::set-output name=upload_url::https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets{?name,label}"
- name: Upload Release Assets
uses: bgpat/release-asset-action@03b0c30db1c4031ce3474740b0e4275cd7e126a3
with:
pattern: "toDeploy/*"
github-token: ${{ secrets.GITHUB_TOKEN }}
release-url: ${{ steps.release-id.outputs.upload_url }}
allow-overwrite: true
call-workflow-passing-data:
needs: build-upload
uses: ./.github/workflows/manual_docs.yml
-23
View File
@@ -1,23 +0,0 @@
name: Close inactive issues or PR
on:
schedule:
- cron: "30 0 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v4.1.1
with:
days-before-issue-stale: 90
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 90 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: 90
days-before-pr-close: 14
repo-token: ${{ secrets.GITHUB_TOKEN }}
exempt-issue-labels: "enhancement"