mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-12-06 06:15:03 +00:00
453 lines
14 KiB
YAML
453 lines
14 KiB
YAML
name: build firmware
|
|
|
|
# Release pipeline; rationale for the caches, pins and publish steps: LLD 01 §19.
|
|
|
|
on:
|
|
push:
|
|
branches: [ "master" ]
|
|
|
|
# Queue, never cancel: a cancelled release run can leave no release at all.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
zephyr_sdk: 1.0.1
|
|
python_version: 3.12
|
|
toolchains: arm-zephyr-eabi:xtensa-espressif_esp32s3_zephyr-elf:xtensa-espressif_esp32_zephyr-elf:riscv64-zephyr-elf
|
|
# "true": mark the release pre-release and skip publish-catalog (firmware-dist keeps the last release).
|
|
prerelease: "false"
|
|
|
|
# Runner image and third-party actions are pinned (third-party to a commit SHA, version in a comment).
|
|
|
|
jobs:
|
|
# Warms the west modules cache (with both BLE blobs); the only writer of that cache.
|
|
setup-zephyr:
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
|
|
# Keyed on the manifest, exact hit or clean fetch only.
|
|
- uses: actions/cache@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
enable-ccache: 'false'
|
|
|
|
- name: Download vendor BLE controller blobs
|
|
run: |
|
|
west blobs fetch hal_espressif
|
|
west blobs fetch hal_silabs
|
|
|
|
build-nrf:
|
|
needs: setup-zephyr
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/cache/restore@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
# ccache namespaced per job.
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
ccache-cache-key: ${{ github.job }}
|
|
|
|
- name: build firmwares
|
|
run: bash build.sh nrf
|
|
|
|
# Roles no manifest publishes: compiled, not packaged.
|
|
- name: compile-only roles
|
|
run: west build -b rak4631 zephcore --pristine -- -DEXTRA_CONF_FILE="boards/common/kiss_modem.conf"
|
|
|
|
- name: ccache stats
|
|
if: always()
|
|
run: ccache -s -vv
|
|
|
|
# Handoff to create-release is an artifact, not a cache: it cannot be evicted mid-run.
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-part-${{ github.job }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
overwrite: true
|
|
|
|
build-esp32-repeaters:
|
|
needs: setup-zephyr
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/cache/restore@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
ccache-cache-key: ${{ github.job }}
|
|
|
|
# No-op when the modules cache hit.
|
|
- name: Download Espressif BLE controller blobs
|
|
run: west blobs fetch hal_espressif
|
|
|
|
- name: build firmwares
|
|
run: bash build.sh esp32 repeaters
|
|
|
|
- name: ccache stats
|
|
if: always()
|
|
run: ccache -s -vv
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-part-${{ github.job }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
overwrite: true
|
|
|
|
build-linux:
|
|
needs: setup-zephyr
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/cache/restore@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
ccache-cache-key: ${{ github.job }}
|
|
|
|
# native_sim targets: femtofox ARMv7-A, rak6421 / rak6421_pi5 aarch64.
|
|
- name: Install cross-compile toolchains
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
|
|
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
|
|
|
- name: build firmwares
|
|
run: bash build.sh linux
|
|
|
|
- name: ccache stats
|
|
if: always()
|
|
run: ccache -s -vv
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-part-${{ github.job }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
overwrite: true
|
|
|
|
# nRF54L15, EFR32MG24 and STM32WL: no USB, bare zephyr.hex, one arm toolchain.
|
|
build-swd:
|
|
needs: setup-zephyr
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/cache/restore@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
ccache-cache-key: ${{ github.job }}
|
|
|
|
# MG24 BLE controller blob; no-op when the modules cache hit.
|
|
- name: Download Silicon Labs BLE controller blobs
|
|
run: west blobs fetch hal_silabs
|
|
|
|
- name: build firmwares
|
|
run: |
|
|
bash build.sh nrf54l
|
|
bash build.sh mg24
|
|
bash build.sh stm32wl
|
|
|
|
- name: ccache stats
|
|
if: always()
|
|
run: ccache -s -vv
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-part-${{ github.job }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
overwrite: true
|
|
|
|
build-esp32-companions:
|
|
needs: setup-zephyr
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
cache: 'pip'
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/cache/restore@v5
|
|
with:
|
|
path: modules
|
|
key: zephyr-modules-${{ runner.os }}-${{ hashFiles('zephcore/west.yml') }}
|
|
|
|
- name: Setup Zephyr project
|
|
uses: zephyrproject-rtos/action-zephyr-setup@be8136a8bba01580485d98b7ad2d32477c36a49a # v1.0.15
|
|
with:
|
|
app-path: zephcore
|
|
toolchains: ${{ env.toolchains }}
|
|
sdk-version: ${{ env.zephyr_sdk }}
|
|
ccache-cache-key: ${{ github.job }}
|
|
|
|
- name: Download Espressif BLE controller blobs
|
|
run: west blobs fetch hal_espressif
|
|
|
|
- name: build firmwares
|
|
run: bash build.sh esp32 companions
|
|
|
|
- name: compile-only roles
|
|
run: west build -b xiao_esp32c3 zephcore --pristine -- -DEXTRA_CONF_FILE="boards/common/kiss_modem.conf"
|
|
|
|
- name: ccache stats
|
|
if: always()
|
|
run: ccache -s -vv
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-part-${{ github.job }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
overwrite: true
|
|
|
|
create-release:
|
|
needs: [build-nrf, build-esp32-companions, build-esp32-repeaters, build-linux,
|
|
build-swd]
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: write
|
|
outputs:
|
|
release_tag: ${{ steps.tag.outputs.release_tag }}
|
|
# env is not readable in a job-level `if:`, so publish-catalog gates on this.
|
|
prerelease: ${{ env.prerelease }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
# Tag = ZEPHCORE_FIRMWARE_VERSION; re-pushing without a bump replaces that release.
|
|
- name: derive release tag from firmware version
|
|
id: tag
|
|
run: |
|
|
version=$(sed -n 's/^set(ZEPHCORE_FIRMWARE_VERSION "\(.*\)")/\1/p' zephcore/CMakeLists.txt)
|
|
if [ -z "$version" ]; then
|
|
echo "::error::Could not read ZEPHCORE_FIRMWARE_VERSION from zephcore/CMakeLists.txt"
|
|
exit 1
|
|
fi
|
|
echo "Release tag / catalog version: $version"
|
|
echo "release_tag=$version" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/download-artifact@v7
|
|
with:
|
|
pattern: firmware-part-*
|
|
merge-multiple: true
|
|
path: firmware
|
|
|
|
- name: verify firmware set arrived
|
|
run: |
|
|
count=$(find firmware -type f 2>/dev/null | wc -l)
|
|
echo "Collected $count firmware files"
|
|
if [ "$count" -eq 0 ]; then
|
|
echo "::error::No firmware files downloaded — the build artifacts did not arrive"
|
|
exit 1
|
|
fi
|
|
ls -la firmware
|
|
|
|
- name: upload firmware artifacts
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-${{ steps.tag.outputs.release_tag }}
|
|
path: firmware
|
|
if-no-files-found: error
|
|
overwrite: true
|
|
|
|
# Body: releasenotes/RELEASE_NOTES_<version>.md; missing only warns.
|
|
- name: resolve release notes
|
|
id: notes
|
|
run: |
|
|
notes="releasenotes/RELEASE_NOTES_${{ steps.tag.outputs.release_tag }}.md"
|
|
if [ -f "$notes" ]; then
|
|
echo "Using release notes: $notes"
|
|
echo "notes_path=$notes" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "::warning::No release notes at $notes — publishing with an empty body"
|
|
: > "${RUNNER_TEMP}/empty_notes.md"
|
|
echo "notes_path=${RUNNER_TEMP}/empty_notes.md" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# Delete an existing release and tag of this version so the rebuild replaces it.
|
|
- name: replace existing release for this version
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
tag="${{ steps.tag.outputs.release_tag }}"
|
|
if gh release view "$tag" >/dev/null 2>&1; then
|
|
echo "Existing release $tag found — deleting it (and its tag) so this build replaces it"
|
|
gh release delete "$tag" --yes --cleanup-tag || true
|
|
else
|
|
echo "No existing release for $tag — creating a new one"
|
|
fi
|
|
|
|
- name: create release
|
|
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ steps.tag.outputs.release_tag }}
|
|
name: Firmware ${{ steps.tag.outputs.release_tag }}
|
|
body_path: ${{ steps.notes.outputs.notes_path }}
|
|
target_commitish: ${{ github.sha }}
|
|
draft: false
|
|
prerelease: ${{ env.prerelease }}
|
|
files: firmware/*
|
|
|
|
# Force-pushes firmware + catalog.json to the firmware-dist branch for the Mesh America configurator
|
|
# (docs/PROVIDER_CATALOG.md). Registered URL:
|
|
# https://raw.githubusercontent.com/<owner>/<repo>/firmware-dist/catalog.json
|
|
publish-catalog:
|
|
needs: create-release
|
|
if: needs.create-release.outputs.prerelease != 'true'
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '${{ env.python_version }}'
|
|
|
|
- run: pip install -r requirements.txt
|
|
|
|
- uses: actions/download-artifact@v7
|
|
with:
|
|
pattern: firmware-part-*
|
|
merge-multiple: true
|
|
path: firmware
|
|
|
|
# An incomplete set here would delete boards from the live feed.
|
|
- name: verify firmware set arrived
|
|
run: |
|
|
count=$(find firmware -type f 2>/dev/null | wc -l)
|
|
echo "Collected $count firmware files"
|
|
if [ "$count" -eq 0 ]; then
|
|
echo "::error::No firmware files downloaded — refusing to force-push an empty firmware-dist"
|
|
exit 1
|
|
fi
|
|
|
|
- name: generate provider catalog
|
|
run: |
|
|
python gen_provider_catalog.py --firmware-dir firmware \
|
|
--url-base "https://cdn.jsdelivr.net/gh/${{ github.repository }}@firmware-dist" \
|
|
--version "${{ needs.create-release.outputs.release_tag }}" \
|
|
--out catalog.json
|
|
|
|
- name: publish firmware + catalog to firmware-dist branch
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
tag="${{ needs.create-release.outputs.release_tag }}"
|
|
work="$(mktemp -d)"
|
|
cp catalog.json "$work/"
|
|
cp firmware/* "$work/"
|
|
{
|
|
echo "# ZephCore firmware-dist"
|
|
echo
|
|
echo "Auto-generated distribution branch for the Mesh America device"
|
|
echo "configurator. Force-pushed by the \`build firmware\` workflow each"
|
|
echo "release -- do not edit by hand."
|
|
echo
|
|
echo "- Catalog (register this URL): https://raw.githubusercontent.com/${{ github.repository }}/firmware-dist/catalog.json"
|
|
echo "- Firmware (jsDelivr): https://cdn.jsdelivr.net/gh/${{ github.repository }}@firmware-dist/"
|
|
echo "- Built from release: $tag"
|
|
} > "$work/README.md"
|
|
cd "$work"
|
|
git init -q -b firmware-dist
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add -A
|
|
git commit -q -m "firmware-dist: $tag"
|
|
git push -f "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" firmware-dist
|