2023-11-13 14:43:27 +01:00
|
|
|
name: Build & Release
|
2021-10-05 16:41:11 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
tags:
|
|
|
|
- v*
|
|
|
|
pull_request:
|
|
|
|
release:
|
|
|
|
types: [published]
|
2021-03-14 15:34:37 +01:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2023-11-12 21:02:50 +01:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
env: [esp32, esp32c3, esp32c3-cdc, esp32s3, esp32s3-cdc, esp32-verbose, esp32c3-verbose, esp32s3-verbose, m5stickc, m5stickc-plus, m5atom, macchina-a0]
|
2021-03-14 15:34:37 +01:00
|
|
|
steps:
|
2023-09-07 02:40:37 +02:00
|
|
|
- uses: actions/checkout@v4
|
2021-03-14 15:34:37 +01:00
|
|
|
- name: Cache pip
|
2024-02-04 15:45:20 +01:00
|
|
|
uses: actions/cache@v4
|
2021-03-14 15:34:37 +01:00
|
|
|
with:
|
|
|
|
path: ~/.cache/pip
|
|
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Cache PlatformIO
|
2024-02-04 15:45:20 +01:00
|
|
|
uses: actions/cache@v4
|
2021-03-14 15:34:37 +01:00
|
|
|
with:
|
2023-11-12 21:57:14 +01:00
|
|
|
path: ~/.platformio/.cache
|
|
|
|
key: ${{ runner.os }}-pio
|
2021-03-14 15:34:37 +01:00
|
|
|
- name: Set up Python
|
2023-12-13 03:44:49 +01:00
|
|
|
uses: actions/setup-python@v5
|
2023-03-11 08:13:34 +01:00
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
|
|
|
- name: Install dependencies
|
2021-03-14 15:34:37 +01:00
|
|
|
run: |
|
2023-03-11 08:13:34 +01:00
|
|
|
pip install wheel
|
|
|
|
pip install -U platformio
|
2022-08-29 19:14:25 +02:00
|
|
|
- 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' }}
|
2023-11-12 20:24:16 +01:00
|
|
|
- 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/') }}
|
2022-08-29 19:14:25 +02:00
|
|
|
- name: Set rel env
|
2021-03-20 03:22:25 +01:00
|
|
|
run: echo "PLATFORMIO_BUILD_FLAGS=-DVERSION='\"${GITHUB_REF#refs/*/}\"'" >> $GITHUB_ENV
|
2021-09-28 16:03:24 +02:00
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2021-03-14 15:34:37 +01:00
|
|
|
- name: Run PlatformIO
|
2023-11-12 21:02:50 +01:00
|
|
|
run: pio run -e ${{ matrix.env }}
|
2023-11-12 21:57:14 +01:00
|
|
|
- name: Rename artifact
|
|
|
|
run: cp .pio/build/${{ matrix.env }}/firmware.bin ${{ matrix.env }}.bin
|
|
|
|
- name: Upload artifact
|
2023-12-19 04:12:23 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-11-12 21:02:50 +01:00
|
|
|
with:
|
|
|
|
name: ${{ matrix.env }}.bin
|
2023-11-12 21:57:14 +01:00
|
|
|
path: ${{ matrix.env }}.bin
|
2023-11-12 21:02:50 +01:00
|
|
|
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
|
2023-12-19 04:12:10 +01:00
|
|
|
uses: actions/download-artifact@v4
|
2023-11-12 21:02:50 +01:00
|
|
|
with:
|
|
|
|
path: artifacts/
|
2021-03-14 15:34:37 +01:00
|
|
|
- name: Release
|
2024-05-02 14:28:06 +02:00
|
|
|
uses: softprops/action-gh-release@v2
|
2021-03-14 15:34:37 +01:00
|
|
|
with:
|
2023-11-12 21:19:31 +01:00
|
|
|
files: artifacts/**/*.bin
|
2021-03-14 15:34:37 +01:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|