ESPresense/.github/workflows/build.yml

75 lines
2.5 KiB
YAML
Raw Permalink Normal View History

2023-11-13 14:43:27 +01:00
name: Build & Release
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:
- uses: actions/checkout@v4
2021-03-14 15:34:37 +01:00
- name: Cache pip
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
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
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
- 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/') }}
- 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
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
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
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 }}