Skip to content

Build and Push Releases #962

Build and Push Releases

Build and Push Releases #962

Workflow file for this run

---
name: Build and Push Releases
on:
push:
branches:
- main, workflow
tags:
- "*"
workflow_dispatch:
jobs:
compile_sketch:
name: Build ${{ matrix.board.env }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- { env: "m5stack-cardputer", family: "ESP32-S3",}
- { env: "m5stack-cplus2", family: "ESP32",}
- { env: "m5stack-cplus1_1", family: "ESP32",}
- { env: "LAUNCHER_m5stack-cplus1_1", family: "ESP32",}
- { env: "m5stack-core2", family: "ESP32",}
- { env: "m5stack-core16mb", family: "ESP32",}
- { env: "m5stack-core4mb", family: "ESP32",}
- { env: "m5stack-cores3", family: "ESP32-S3",}
- { env: "esp32-s3-devkitc-1", family: "ESP32-S3",}
- { env: "esp32-c5", family: "ESP32-C5",}
- { env: "esp32-c5-tft", family: "ESP32-C5",}
- { env: "CYD-2432S028", family: "ESP32",}
- { env: "CYD-2USB", family: "ESP32",}
- { env: "CYD-2432W328C", family: "ESP32",}
- { env: "CYD-2432W328C_2", family: "ESP32",}
- { env: "CYD-2432W328R-or-S024R", family: "ESP32",}
- { env: "LAUNCHER_CYD-2432W328R-or-S024R", family: "ESP32",}
- { env: "LAUNCHER_CYD-2432S028", family: "ESP32",}
- { env: "LAUNCHER_CYD-2USB", family: "ESP32",}
- { env: "LAUNCHER_CYD-2432W328C", family: "ESP32",}
- { env: "lilygo-t-embed-cc1101", family: "ESP32-S3",}
- { env: "lilygo-t-embed", family: "ESP32-S3",}
- { env: "lilygo-t-deck", family: "ESP32-S3",}
- { env: "lilygo-t-watch-s3", family: "ESP32-S3",}
- { env: "lilygo-t-deck-pro", family: "ESP32-S3",}
- { env: "lilygo-t-display-s3", family: "ESP32-S3",}
- { env: "lilygo-t-display-s3-touch", family: "ESP32-S3",}
- { env: "lilygo-t-display-s3-mmc", family: "ESP32-S3",}
- { env: "lilygo-t-display-s3-touch-mmc", family: "ESP32-S3",}
- { env: "lilygo-t-display-S3-pro", family: "ESP32-S3",}
- { env: "lilygo-t-display-ttgo", family: "ESP32",}
- { env: "lilygo-t-hmi", family: "ESP32-S3",}
- { env: "lilygo-t-lora-pager", family: "ESP32-S3",}
- { env: "smoochiee-board", family: "ESP32-S3",}
- { env: "Phantom_S024R", family: "ESP32",}
- { env: "LAUNCHER_Phantom_S024R", family: "ESP32",}
- { env: "Marauder-Mini", family: "ESP32",}
- { env: "LAUNCHER_Marauder-Mini", family: "ESP32",}
- { env: "Awok-Mini", family: "ESP32",}
- { env: "Marauder-v7", family: "ESP32",}
- { env: "LAUNCHER_Marauder-v7", family: "ESP32",}
- { env: "Marauder-V4-V6", family: "ESP32",}
- { env: "Marauder-v61", family: "ESP32",}
- { env: "LAUNCHER_Marauder-V4-V6", family: "ESP32",}
- { env: "LAUNCHER_Marauder-v61", family: "ESP32",}
- { env: "Awok-Touch", family: "ESP32",}
- { env: "WaveSentry-R1", family: "ESP32",}
- { env: "LAUNCHER_WaveSentry-R1", family: "ESP32",}
steps:
- uses: actions/checkout@v4
- id: build
name: setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install build deps (multilib)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gcc-multilib libc6-dev-i386
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
${{ runner.os }}-pip-
- name: Cache PlatformIO Framework
uses: actions/cache@v4
with:
path: |
~/.platformio
key: ${{ runner.os }}-platformio-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-platformio-${{ hashFiles('platformio.ini') }}
${{ runner.os }}-platformio-
- name: PIO libraries cache
uses: actions/cache@v4
with:
path: |
.pio/libdeps
key: ${{ runner.os }}-pio-${{ matrix.board.env }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.board.env }}-${{ hashFiles('platformio.ini') }}
${{ runner.os }}-pio-${{ matrix.board.env }}-
- name: Install dependencies
run: |
pip install requests esptool intelhex
pip install platformio
- name: Prepare PlatformIO file
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
version=${{ github.ref_name }}
else
version="${GITHUB_SHA::7}"
fi
sed -i "s/-DBRUCE_VERSION=/-DBRUCE_VERSION='\"$version\"' ; /g" ./platformio.ini
sed -i "s/-DGIT_COMMIT_HASH='\"Homebrew\"'/\!echo '-DGIT_COMMIT_HASH=\\\\\\\\\"'\$\(git describe --always --dirty)'\\\\\\\\\"'/g" ./platformio.ini
cat ./platformio.ini
- name: Run Compile
run: |
set -o pipefail
platformio run -e ${{ matrix.board.env }} | tee build-${{ matrix.board.env }}.log
- name: Build summary
run: |
if [[ -f build-${{ matrix.board.env }}.log ]]; then
echo "Last 75 lines of build-${{ matrix.board.env }}.log:"
tail -n 75 build-${{ matrix.board.env }}.log
else
echo "Build log not found; nothing to show."
fi
- name: Upload ${{ matrix.board.env }}
uses: actions/upload-artifact@v4
with:
name: Bruce-${{ matrix.board.env }}
path: Bruce-*.*
retention-days: 1
if-no-files-found: error
post_compile_steps:
name: Update Placeholders
runs-on: ubuntu-latest
environment: github_release
needs: compile_sketch
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') || github.ref_type == 'tag'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: '*'
merge-multiple: true
path: artifacts
- name: Ensure releases exist and get IDs
id: get_release
uses: actions/github-script@v7
with:
script: |
const ensureByTag = async (tag, prerelease=true) => {
try {
const { data } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag
});
return data.id;
} catch (e) {
if (e.status !== 404) throw e;
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
prerelease
});
return data.id;
}
};
const betaId = await ensureByTag('betaRelease');
const lastId = await ensureByTag('lastRelease');
core.setOutput('beta', String(betaId));
core.setOutput('last', String(lastId));
- name: Get current sha
id: get_sha
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Delete old betaRelease assets
uses: actions/github-script@v6
with:
script: |
const release_id = ${{ steps.get_release.outputs.beta }};
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id
});
for (const asset of assets.data) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
- name: Upload new betaRelease asset
uses: softprops/action-gh-release@v2
with:
name: betaRelease commit (${{ steps.get_sha.outputs.GITHUB_SHA_SHORT }})
tag_name: betaRelease
prerelease: true
files: artifacts/**
fail_on_unmatched_files: false
make_latest: false
generate_release_notes: false
- name: Delete old lastRelease assets
uses: actions/github-script@v6
if: github.ref_type == 'tag'
with:
script: |
const release_id = ${{ steps.get_release.outputs.last }};
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id
});
for (const asset of assets.data) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
- name: Upload new lastRelease asset
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
name: lastRelease commit (${{ steps.get_sha.outputs.GITHUB_SHA_SHORT }})
tag_name: lastRelease
prerelease: true
files: artifacts/**
fail_on_unmatched_files: false
make_latest: false
generate_release_notes: false
- name: Checkout main to trigger WebPage deploy
if: ${{ success() }}
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 1
- name: Trigger WebPage deploy (workflow_dispatch)
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow list
gh workflow run .github/workflows/deploy.yml --ref WebPage
create_release:
runs-on: ubuntu-latest
environment: github_release
needs: [compile_sketch]
if: github.ref_type == 'tag'
steps:
- id: bruce_version
name: Get Version
run: |
set -x
if [[ "${{ github.ref_type }}" == "tag" ]]; then
version=${{ github.ref_name }}
else
version="${GITHUB_SHA::7}"
fi
echo "version=${version}" > $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List all files
if: always()
run: |
set -x
pwd
ls -all
tree
- name: Create Release ${{ steps.bruce_version.outputs.version }}
uses: softprops/action-gh-release@v1
with:
name: Bruce Release ${{ steps.bruce_version.outputs.version }}
tag_name: ${{ steps.bruce_version.outputs.version }}
generate_release_notes: true
files: |
Bruce-*.bin