mirror of
https://github.com/meshtastic/firmware.git
synced 2026-06-02 05:10:06 -04:00
* Improved flow to make easier The emojis are intentional! I had minimal LLM input!!! * try and fix input variable sanitisation * and again * again * Copilot fixed it for me * copilot didn't fix it for me * copilot might have fixed it and I broke it by copypasting --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
176 lines
5.9 KiB
YAML
176 lines
5.9 KiB
YAML
name: Build One Target
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
# trunk-ignore(checkov/CKV_GHA_7)
|
|
target:
|
|
type: string
|
|
required: false
|
|
description: Choose the target board, e.g. nrf52_promicro_diy_tcxo. If blank, will find available targets.
|
|
arch:
|
|
type: choice
|
|
options:
|
|
- all
|
|
- esp32
|
|
- esp32s3
|
|
- esp32c3
|
|
- esp32c6
|
|
- nrf52840
|
|
- rp2040
|
|
- rp2350
|
|
- stm32
|
|
description: Choose an arch to limit the search, or 'all' to search all architectures.
|
|
default: all
|
|
|
|
permissions: read-all
|
|
|
|
jobs:
|
|
find-targets:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
arch:
|
|
- all
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: 3.x
|
|
cache: pip
|
|
- run: pip install -U platformio
|
|
- name: Generate matrix
|
|
id: jsonStep
|
|
env:
|
|
BUILDTARGET: ${{ inputs.target }}
|
|
MATRIXARCH: ${{ inputs.arch }}
|
|
run: |
|
|
TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}} --level extra)
|
|
if [ "$BUILDTARGET" = "" ]; then
|
|
echo "Name: $GITHUB_REF_NAME" >> $GITHUB_STEP_SUMMARY
|
|
echo "Base: $GITHUB_BASE_REF" >> $GITHUB_STEP_SUMMARY
|
|
echo "Arch: $MATRIXARCH" >> $GITHUB_STEP_SUMMARY
|
|
echo "Ref: $GITHUB_REF" >> $GITHUB_STEP_SUMMARY
|
|
echo "## 🎯 The following target boards are available to build:" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Platform | Board |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| -------- | ----- |" >> $GITHUB_STEP_SUMMARY
|
|
echo $TARGETS | jq -r 'sort_by(.board) | sort_by(.platform) |.[] | "| " + .platform + " | " + .board + " |" ' >> $GITHUB_STEP_SUMMARY
|
|
else
|
|
echo "We build this one:" >> $GITHUB_STEP_SUMMARY
|
|
ARCH=$(echo "$TARGETS" | jq --arg BUILDTARGET "$BUILDTARGET" -r '.[] | select(.board==$BUILDTARGET) | .platform')
|
|
echo "| Platform | Board |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| -------- | ----- |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| $ARCH | "$BUILDTARGET" |" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
if [[ "$ARCH" == "" ]]; then
|
|
echo "## ❌ Error: Target "$BUILDTARGET" not found!" >> $GITHUB_STEP_SUMMARY
|
|
else
|
|
echo "## ✅ Target "$BUILDTARGET" found, proceeding to build." >> $GITHUB_STEP_SUMMARY
|
|
fi
|
|
echo "You may need to refresh this page to make the built firmware appear below." >> $GITHUB_STEP_SUMMARY
|
|
echo "arch=$ARCH" >> $GITHUB_OUTPUT
|
|
fi
|
|
outputs:
|
|
arch: ${{ steps.jsonStep.outputs.arch }}
|
|
|
|
version:
|
|
if: ${{ inputs.target != '' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- name: Get release version string
|
|
run: |
|
|
echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
|
echo "deb=$(./bin/buildinfo.py deb)" >> $GITHUB_OUTPUT
|
|
id: version
|
|
env:
|
|
BUILD_LOCATION: local
|
|
outputs:
|
|
long: ${{ steps.version.outputs.long }}
|
|
deb: ${{ steps.version.outputs.deb }}
|
|
|
|
build:
|
|
if: ${{ inputs.target != '' && inputs.arch != 'native' }}
|
|
needs: [version, find-targets]
|
|
uses: ./.github/workflows/build_firmware.yml
|
|
with:
|
|
version: ${{ needs.version.outputs.long }}
|
|
pio_env: ${{ inputs.target }}
|
|
platform: ${{ needs.find-targets.outputs.arch }}
|
|
|
|
gather-artifacts:
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
runs-on: ubuntu-latest
|
|
needs: [version, build]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{github.event.pull_request.head.ref}}
|
|
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
path: ./
|
|
pattern: firmware-*-*
|
|
merge-multiple: true
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -R
|
|
|
|
- name: Move files up
|
|
run: mv -b -t ./ ./bin/device-*.sh ./bin/device-*.bat
|
|
|
|
- name: Repackage in single firmware zip
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: firmware-${{inputs.target}}-${{ needs.version.outputs.long }}
|
|
overwrite: true
|
|
path: |
|
|
./firmware-*.bin
|
|
./firmware-*.uf2
|
|
./firmware-*.hex
|
|
./firmware-*.zip
|
|
./device-*.sh
|
|
./device-*.bat
|
|
./littlefs-*.bin
|
|
./bleota*bin
|
|
./Meshtastic_nRF52_factory_erase*.uf2
|
|
retention-days: 30
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: firmware-*-${{ needs.version.outputs.long }}
|
|
merge-multiple: true
|
|
path: ./output
|
|
|
|
# For diagnostics
|
|
- name: Show artifacts
|
|
run: ls -lR
|
|
|
|
- name: Device scripts permissions
|
|
run: |
|
|
chmod +x ./output/device-install.sh || true
|
|
chmod +x ./output/device-update.sh || true
|
|
|
|
- name: Zip firmware
|
|
run: zip -j -9 -r ./firmware-${{inputs.target}}-${{ needs.version.outputs.long }}.zip ./output
|
|
|
|
- name: Repackage in single elfs zip
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: debug-elfs-${{inputs.target}}-${{ needs.version.outputs.long }}.zip
|
|
overwrite: true
|
|
path: ./*.elf
|
|
retention-days: 30
|
|
|
|
- uses: scruplelesswizard/comment-artifact@main
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
with:
|
|
name: firmware-${{inputs.target}}-${{ needs.version.outputs.long }}
|
|
description: "Download firmware-${{inputs.target}}-${{ needs.version.outputs.long }}.zip. This artifact will be available for 90 days from creation"
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|