mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-07-18 17:46:22 +00:00
117 lines
3.4 KiB
YAML
117 lines
3.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
|
|
jobs:
|
|
format:
|
|
name: Format Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install clang-format
|
|
run: sudo apt-get update && sudo apt-get install -y clang-format-14
|
|
|
|
- name: Verify formatting
|
|
run: |
|
|
clang-format-14 --version
|
|
git ls-files -z '*.c' '*.cpp' '*.h' '*.hpp' ':(exclude)modules/core_chat/generated/**' \
|
|
':(exclude)modules/ui_shared/include/ui/assets/**' \
|
|
':(exclude)modules/ui_shared/src/ui/assets/**' \
|
|
':(exclude)platform/nrf52/arduino_common/include/ui/fonts/**' \
|
|
':(exclude)platform/nrf52/arduino_common/src/ui/fonts/**' \
|
|
':(exclude)third_party/codec2/**' \
|
|
| xargs -0 clang-format-14 --dry-run --Werror
|
|
|
|
build:
|
|
name: PlatformIO Build (${{ matrix.env }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
env:
|
|
- tlora_pager_sx1262
|
|
- tdeck
|
|
- lilygo_twatch_s3
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract version
|
|
id: version
|
|
run: |
|
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
VERSION="${GITHUB_REF_NAME#v}"
|
|
else
|
|
VERSION=$(iconv -f UTF-16LE -t UTF-8 CHANGELOG.md | awk -F'[][]' '/^## \\[[0-9]/ {print $2; exit}')
|
|
fi
|
|
if [ -z "$VERSION" ]; then
|
|
VERSION="unknown"
|
|
fi
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Cache PlatformIO
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.platformio
|
|
key: ${{ runner.os }}-platformio-${{ hashFiles('platformio.ini') }}
|
|
|
|
- name: Install PlatformIO
|
|
run: python -m pip install --upgrade platformio
|
|
|
|
- name: Build (${{ matrix.env }})
|
|
run: pio run -e ${{ matrix.env }}
|
|
|
|
- name: Collect firmware
|
|
run: |
|
|
mkdir -p dist
|
|
cp .pio/build/${{ matrix.env }}/firmware.bin dist/trail-mate-${{ matrix.env }}-v${{ steps.version.outputs.version }}.bin
|
|
|
|
- name: Upload firmware artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: trail-mate-${{ matrix.env }}-v${{ steps.version.outputs.version }}
|
|
path: dist/trail-mate-${{ matrix.env }}-v${{ steps.version.outputs.version }}.bin
|
|
|
|
release:
|
|
name: Publish GitHub Release
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- format
|
|
- build
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Download firmware artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist
|
|
|
|
- name: Verify collected firmware files
|
|
run: |
|
|
find dist -type f -name '*.bin' -print | sort
|
|
|
|
- name: Create or update release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
name: ${{ github.ref_name }}
|
|
generate_release_notes: true
|
|
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}
|
|
overwrite_files: true
|
|
files: |
|
|
dist/**/*.bin
|