75 lines
2.5 KiB
YAML
75 lines
2.5 KiB
YAML
name: Build & Release
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- v*
|
|
pull_request:
|
|
release:
|
|
types: [published]
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
env: [esp32, esp32c3, esp32c3-cdc, esp32s3, esp32s3-cdc, esp32-verbose, esp32c3-verbose, esp32s3-verbose, m5stickc, m5stickc-plus, m5atom, macchina-a0]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Cache pip
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
- name: Cache PlatformIO
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.platformio/.cache
|
|
key: ${{ runner.os }}-pio
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.x'
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install wheel
|
|
pip install -U platformio
|
|
- name: Setup github_head_sha
|
|
run: echo "GITHUB_HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
- name: Set pr env
|
|
run: echo "PLATFORMIO_BUILD_FLAGS=-DBRANCH='\"${GITHUB_HEAD_REF}\"' -DVERSION='\"${GITHUB_HEAD_SHA::7}\"'" >> $GITHUB_ENV
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
- name: Set branch env
|
|
run: echo "PLATFORMIO_BUILD_FLAGS=-DBRANCH='\"${GITHUB_REF#refs/heads/}\"' -DVERSION='\"${GITHUB_SHA::7}\"'" >> $GITHUB_ENV
|
|
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') }}
|
|
- name: Set rel env
|
|
run: echo "PLATFORMIO_BUILD_FLAGS=-DVERSION='\"${GITHUB_REF#refs/*/}\"'" >> $GITHUB_ENV
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
- name: Run PlatformIO
|
|
run: pio run -e ${{ matrix.env }}
|
|
- name: Rename artifact
|
|
run: cp .pio/build/${{ matrix.env }}/firmware.bin ${{ matrix.env }}.bin
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.env }}.bin
|
|
path: ${{ matrix.env }}.bin
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: build # This job needs to wait for all matrix builds to complete
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts/
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: artifacts/**/*.bin
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|