mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
implement matrix builds for faster firmware releases
This commit is contained in:
@@ -25,5 +25,14 @@ runs:
|
|||||||
- name: Extract Version from Git Tag
|
- name: Extract Version from Git Tag
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
GIT_TAG_NAME="${GITHUB_REF#refs/tags/}"
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
echo "GIT_TAG_VERSION=${GIT_TAG_NAME##*-}" >> $GITHUB_ENV
|
# triggered by a tag push (e.g: refs/tags/companion-v1.2.3)
|
||||||
|
GIT_TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||||
|
VERSION_STRING="${GIT_TAG_NAME##*-}"
|
||||||
|
else
|
||||||
|
# triggered by a workflow dispatch (e.g: refs/heads/main)
|
||||||
|
# strip "refs/heads/" prefix and replace any remaining "/" with "-" to protect file paths
|
||||||
|
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
|
||||||
|
VERSION_STRING=$(echo "$BRANCH_NAME" | tr '/' '-')
|
||||||
|
fi
|
||||||
|
echo "GIT_TAG_VERSION=${VERSION_STRING}" >> $GITHUB_ENV
|
||||||
|
|||||||
35
.github/workflows/build-companion-firmwares.yml
vendored
35
.github/workflows/build-companion-firmwares.yml
vendored
@@ -10,33 +10,8 @@ on:
|
|||||||
- 'companion-*'
|
- 'companion-*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-companion-firmwares:
|
||||||
build:
|
uses: ./.github/workflows/firmware-builder.yml
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
steps:
|
firmware_type: 'companion'
|
||||||
|
release_title_prefix: 'Companion Firmware'
|
||||||
- name: Clone Repo
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Build Environment
|
|
||||||
uses: ./.github/actions/setup-build-environment
|
|
||||||
|
|
||||||
- name: Build Firmwares
|
|
||||||
env:
|
|
||||||
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
|
|
||||||
run: /usr/bin/env bash build.sh build-companion-firmwares
|
|
||||||
|
|
||||||
- name: Upload Workflow Artifacts
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: companion-firmwares
|
|
||||||
path: out
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v3
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
name: Companion Firmware ${{ env.GIT_TAG_VERSION }}
|
|
||||||
body: ""
|
|
||||||
draft: true
|
|
||||||
files: out/*
|
|
||||||
|
|||||||
35
.github/workflows/build-repeater-firmwares.yml
vendored
35
.github/workflows/build-repeater-firmwares.yml
vendored
@@ -10,33 +10,8 @@ on:
|
|||||||
- 'repeater-*'
|
- 'repeater-*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-repeater-firmwares:
|
||||||
build:
|
uses: ./.github/workflows/firmware-builder.yml
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
steps:
|
firmware_type: 'repeater'
|
||||||
|
release_title_prefix: 'Repeater Firmware'
|
||||||
- name: Clone Repo
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Build Environment
|
|
||||||
uses: ./.github/actions/setup-build-environment
|
|
||||||
|
|
||||||
- name: Build Firmwares
|
|
||||||
env:
|
|
||||||
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
|
|
||||||
run: /usr/bin/env bash build.sh build-repeater-firmwares
|
|
||||||
|
|
||||||
- name: Upload Workflow Artifacts
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: repeater-firmwares
|
|
||||||
path: out
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v3
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
name: Repeater Firmware ${{ env.GIT_TAG_VERSION }}
|
|
||||||
body: ""
|
|
||||||
draft: true
|
|
||||||
files: out/*
|
|
||||||
|
|||||||
@@ -10,33 +10,8 @@ on:
|
|||||||
- 'room-server-*'
|
- 'room-server-*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-room-server-firmwares:
|
||||||
build:
|
uses: ./.github/workflows/firmware-builder.yml
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
steps:
|
firmware_type: 'room-server'
|
||||||
|
release_title_prefix: 'Room Server Firmware'
|
||||||
- name: Clone Repo
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup Build Environment
|
|
||||||
uses: ./.github/actions/setup-build-environment
|
|
||||||
|
|
||||||
- name: Build Firmwares
|
|
||||||
env:
|
|
||||||
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
|
|
||||||
run: /usr/bin/env bash build.sh build-room-server-firmwares
|
|
||||||
|
|
||||||
- name: Upload Workflow Artifacts
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: room-server-firmwares
|
|
||||||
path: out
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v3
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
name: Room Server Firmware ${{ env.GIT_TAG_VERSION }}
|
|
||||||
body: ""
|
|
||||||
draft: true
|
|
||||||
files: out/*
|
|
||||||
|
|||||||
90
.github/workflows/firmware-builder.yml
vendored
Normal file
90
.github/workflows/firmware-builder.yml
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
name: Firmware Builder
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
firmware_type:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
release_title_prefix:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
generate-build-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
targets: ${{ steps.get-build-targets.outputs.targets }}
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Clone Repo
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Build Environment
|
||||||
|
uses: ./.github/actions/setup-build-environment
|
||||||
|
|
||||||
|
- name: Get Build Targets
|
||||||
|
id: get-build-targets
|
||||||
|
run: |
|
||||||
|
# get list of firmwares to build
|
||||||
|
TARGET_LIST=$(/usr/bin/env bash build.sh get-${{ inputs.firmware_type }}-firmwares-to-build)
|
||||||
|
|
||||||
|
# convert targets separated by new line into a json array string
|
||||||
|
JSON_ARRAY=$(echo "$TARGET_LIST" | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
||||||
|
|
||||||
|
# use json array as targets result
|
||||||
|
echo "targets=$JSON_ARRAY" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: generate-build-matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true # don't fail entire build if one board fails to build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJson(needs.generate-build-matrix.outputs.targets) }}
|
||||||
|
fail-fast: false # don't cancel other builds if one board fails to build
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Clone Repo
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Build Environment
|
||||||
|
uses: ./.github/actions/setup-build-environment
|
||||||
|
|
||||||
|
- name: Build Firmware
|
||||||
|
env:
|
||||||
|
FIRMWARE_VERSION: ${{ env.GIT_TAG_VERSION }}
|
||||||
|
run: /usr/bin/env bash build.sh build-firmware ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Upload Workflow Artifacts
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: "${{ matrix.target }}"
|
||||||
|
path: out
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/') # only create release for tagged builds
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Clone Repo
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup Build Environment
|
||||||
|
uses: ./.github/actions/setup-build-environment
|
||||||
|
|
||||||
|
- name: Download All Artifacts
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
merge-multiple: true
|
||||||
|
path: out
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v3
|
||||||
|
with:
|
||||||
|
name: "${{ inputs.release_title_prefix }} ${{ env.GIT_TAG_VERSION }}"
|
||||||
|
body: ""
|
||||||
|
draft: true
|
||||||
|
files: out/*
|
||||||
10
build.sh
10
build.sh
@@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
global_usage() {
|
global_usage() {
|
||||||
cat - <<EOF
|
cat - <<EOF
|
||||||
Usage:
|
Usage:
|
||||||
@@ -275,4 +278,11 @@ elif [[ $1 == "build-repeater-firmwares" ]]; then
|
|||||||
build_repeater_firmwares
|
build_repeater_firmwares
|
||||||
elif [[ $1 == "build-room-server-firmwares" ]]; then
|
elif [[ $1 == "build-room-server-firmwares" ]]; then
|
||||||
build_room_server_firmwares
|
build_room_server_firmwares
|
||||||
|
elif [[ $1 == "get-companion-firmwares-to-build" ]]; then
|
||||||
|
get_pio_envs_ending_with_string "_companion_radio_usb"
|
||||||
|
get_pio_envs_ending_with_string "_companion_radio_ble"
|
||||||
|
elif [[ $1 == "get-repeater-firmwares-to-build" ]]; then
|
||||||
|
get_pio_envs_ending_with_string "_repeater"
|
||||||
|
elif [[ $1 == "get-room-server-firmwares-to-build" ]]; then
|
||||||
|
get_pio_envs_ending_with_string "_room_server"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user