Skip to content

set GDOOR_VERSION via PLATFORMIO_BUILD_FLAGS #40

set GDOOR_VERSION via PLATFORMIO_BUILD_FLAGS

set GDOOR_VERSION via PLATFORMIO_BUILD_FLAGS #40

Workflow file for this run

name: PlatformIO CI
on:
push:
paths: # only run if firmware changes
- 'firmware/**'
- '.github/workflows/firmware.yml'
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./firmware/esp32/gdoor
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Set GDOOR_VERSION environment variable
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${GITHUB_REF#refs/heads/}
fi
SHORT_SHA=$(git rev-parse --short HEAD)
GDOOR_VERSION=${VERSION}+${SHORT_SHA}
echo GDOOR_VERSION=${GDOOR_VERSION} >> $GITHUB_ENV
echo PLATFORMIO_BUILD_FLAGS="-DGDOOR_VERSION=\\\"${GDOOR_VERSION}\\\"" >> $GITHUB_ENV
echo GDOOR_VERSION=${GDOOR_VERSION}
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build PlatformIO Project
run: pio run
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: gdoor_firmware
path: |
./firmware/esp32/gdoor/.pio/build/GDOOR_ESP32MINI/*.bin
./firmware/esp32/gdoor/.pio/build/GDOOR_ESP32MINI/web
release:
if: startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-hardware')
runs-on: ubuntu-latest
needs: build
steps:
- name: Download production artifacts
uses: actions/download-artifact@v4
with:
name: gdoor_firmware
- name: Set GDOOR_VERSION environment variable
run: echo "GDOOR_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: "Firmware ${{ env.GDOOR_VERSION }}"
files: ./*.bin
draft: true
- name: Push firmware to website repo for web installer
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: './web'
target-directory: 'assets/firmware'
destination-github-username: 'gdoor-org'
destination-repository-name: 'gdoor-org.github.io'
target-branch: main
user-name: 'github-actions[bot]'
commit-message: 'Latest firmware for web installer via ORIGIN_COMMIT'