Skip to content

git workflow

git workflow #1

name: ESP32C5 Build (IDF release-v6.0)
on:
workflow_dispatch:
inputs:
release_tag:
description: "Optional tag name to upload assets to a release (example 'v0.5.1')"
required: false
build_pages:
description: "Build and deploy GitHub Pages"
required: false
type: choice
options:
- "false"
- "true"
default: "false"
push:
branches: [main, master]
paths:
- "ESP32C5/main/**"
- "ESP32C5/components/**"
- "ESP32C5/CMakeLists.txt"
- "ESP32C5/sdkconfig"
- "ESP32C5/partitions.csv"
- "ESP32C5/post_build.cmake"
- "ESP32C5/.github/scripts/**"
- ".github/workflows/esp32c5-build-master.yml"
- "ESP32C5/docs/index.html"
release:
types: [published, edited]
env:
FW_BASENAME: pancake-esp32c5
jobs:
build:
name: Build ESP32-C5
permissions:
contents: read
runs-on: ubuntu-24.04
container:
image: espressif/idf:release-v6.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache ESP-IDF artifacts
uses: actions/cache@v4
with:
path: /root/.espressif
key: espidf-release-v6.0-${{ runner.os }}-${{ hashFiles('ESP32C5/sdkconfig', 'ESP32C5/main/idf_component.yml', 'ESP32C5/components/**/idf_component.yml') }}
restore-keys: |
espidf-release-v6.0-${{ runner.os }}-
espidf-release-v6.0-
- name: Build firmware
run: bash ESP32C5/.github/scripts/container_build.sh --no-docker
- name: Upload raw firmware artifacts
uses: actions/upload-artifact@v4
with:
name: esp32c5-firmware-raw
path: ESP32C5/binaries-esp32c5
if-no-files-found: error
package:
name: Package Release Artifacts
needs: [build]
permissions:
contents: read
runs-on: ubuntu-24.04
outputs:
fw_version: ${{ steps.prepare.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download raw firmware artifacts
uses: actions/download-artifact@v4
with:
name: esp32c5-firmware-raw
path: release_artifacts/firmware
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Prepare versioned artifacts
id: prepare
shell: bash
run: |
set -euo pipefail
version=$(python - <<'PY'
from pathlib import Path
import re
text = Path("ESP32C5/components/wifi_cli/include/wifi_common.h").read_text()
match = re.search(r'#define\s+JANOS_VERSION\s+"([^"]+)"', text)
if not match:
raise SystemExit("JANOS_VERSION not found")
print(match.group(1))
PY
)
out_dir="release_artifacts/firmware"
app_src="${out_dir}/projectZero.bin"
if [ ! -f "$app_src" ]; then
echo "Missing firmware: $app_src" >&2
exit 1
fi
cp "ESP32C5/.github/scripts/flash_board.py" "${out_dir}/flash_board.py"
cp "${out_dir}/bootloader.bin" "${out_dir}/bootloader-esp32c5.bin"
cp "${out_dir}/partition-table.bin" "${out_dir}/partition-table-esp32c5.bin"
cp "$app_src" "${out_dir}/${FW_BASENAME}.bin"
cp "$app_src" "${out_dir}/${FW_BASENAME}-${version}.bin"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Merge full flash image
shell: bash
run: |
set -euo pipefail
python -m pip install --disable-pip-version-check --no-cache-dir esptool
out_dir="release_artifacts/firmware"
python -m esptool --chip esp32c5 merge_bin \
-o "${out_dir}/${FW_BASENAME}-full-${{ steps.prepare.outputs.version }}.bin" \
--flash_mode dio --flash_freq 80m --flash_size 8MB \
0x2000 "${out_dir}/bootloader.bin" \
0x8000 "${out_dir}/partition-table.bin" \
0x10000 "${out_dir}/projectZero.bin"
cp "${out_dir}/${FW_BASENAME}-full-${{ steps.prepare.outputs.version }}.bin" \
"${out_dir}/${FW_BASENAME}-full.bin"
- name: Package firmware bundle
shell: bash
run: |
set -euo pipefail
cd release_artifacts/firmware
out="${FW_BASENAME}-${{ steps.prepare.outputs.version }}.zip"
rm -f "$out"
zip -9 "$out" \
flash_board.py \
bootloader.bin \
bootloader-esp32c5.bin \
partition-table.bin \
partition-table-esp32c5.bin \
projectZero.bin \
"${FW_BASENAME}.bin" \
"${FW_BASENAME}-${{ steps.prepare.outputs.version }}.bin" \
"${FW_BASENAME}-full.bin" \
"${FW_BASENAME}-full-${{ steps.prepare.outputs.version }}.bin"
- name: Upload packaged artifacts
uses: actions/upload-artifact@v4
with:
name: esp32c5-firmware-release
path: release_artifacts/firmware
if-no-files-found: error
release:
name: Release
needs: [package]
permissions:
contents: write
runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
steps:
- name: Resolve release tag
id: meta
env:
EVENT_TAG: ${{ github.event.release.tag_name }}
INPUT_TAG: ${{ inputs.release_tag }}
FW_VERSION: ${{ needs.package.outputs.fw_version }}
run: |
set -euo pipefail
TAG="${EVENT_TAG:-}"
if [ -z "$TAG" ]; then TAG="${INPUT_TAG:-}"; fi
if [ -z "$TAG" ]; then TAG="v${FW_VERSION}"; fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using tag: $TAG"
- name: Download packaged artifacts
uses: actions/download-artifact@v4
with:
name: esp32c5-firmware-release
path: release_artifacts/firmware
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: ${{ format('v{0} - pancake ESP32-C5', needs.package.outputs.fw_version) }}
overwrite_files: true
files: |
release_artifacts/firmware/flash_board.py
release_artifacts/firmware/bootloader.bin
release_artifacts/firmware/bootloader-esp32c5.bin
release_artifacts/firmware/partition-table.bin
release_artifacts/firmware/partition-table-esp32c5.bin
release_artifacts/firmware/projectZero.bin
release_artifacts/firmware/${{ env.FW_BASENAME }}.bin
release_artifacts/firmware/${{ env.FW_BASENAME }}-${{ needs.package.outputs.fw_version }}.bin
release_artifacts/firmware/${{ env.FW_BASENAME }}-full.bin
release_artifacts/firmware/${{ env.FW_BASENAME }}-full-${{ needs.package.outputs.fw_version }}.bin
release_artifacts/firmware/${{ env.FW_BASENAME }}-${{ needs.package.outputs.fw_version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pages:
name: Pages Download Hub
needs: [release, package]
if: ${{ needs.release.result == 'success' && (github.event_name != 'workflow_dispatch' || inputs.build_pages == 'true') }}
runs-on: ubuntu-24.04
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs:
page_url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Resolve release tag
id: meta
env:
EVENT_TAG: ${{ github.event.release.tag_name }}
INPUT_TAG: ${{ inputs.release_tag }}
FW_VERSION: ${{ needs.package.outputs.fw_version }}
run: |
set -euo pipefail
TAG="${EVENT_TAG:-}"
if [ -z "$TAG" ]; then TAG="${INPUT_TAG:-}"; fi
if [ -z "$TAG" ]; then TAG="v${FW_VERSION}"; fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using tag: $TAG"
- name: Download release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
rm -rf ESP32C5/docs/firmware ESP32C5/docs/manifest.json
mkdir -p ESP32C5/docs/firmware
gh release download "$TAG" -R "$GITHUB_REPOSITORY" --dir ESP32C5/docs/firmware \
--pattern "flash_board.py" \
--pattern "bootloader.bin" \
--pattern "partition-table.bin" \
--pattern "${FW_BASENAME}.bin" \
--pattern "${FW_BASENAME}-full.bin"
for f in flash_board.py bootloader.bin partition-table.bin "${FW_BASENAME}.bin" "${FW_BASENAME}-full.bin"; do
if [ ! -f "ESP32C5/docs/firmware/$f" ]; then
echo "Missing release asset: $f" >&2
exit 1
fi
done
- name: Build manifest.json
env:
FW_VERSION: ${{ needs.package.outputs.fw_version }}
BUILD_TAG: ${{ steps.meta.outputs.tag }}
shell: bash
run: |
set -euo pipefail
python - <<'PY'
import json
import os
from pathlib import Path
manifest = {
"name": "pancake ESP32-C5",
"version": os.environ["FW_VERSION"],
"build": os.environ["BUILD_TAG"],
"chipFamily": "ESP32-C5",
"parts": [
{
"path": "firmware/bootloader.bin",
"offset": 0x2000,
},
{
"path": "firmware/partition-table.bin",
"offset": 0x8000,
},
{
"path": "firmware/pancake-esp32c5.bin",
"offset": 0x10000,
},
],
"builds": [
{
"chipFamily": "ESP32-C5",
"parts": [
{
"path": "firmware/bootloader.bin",
"offset": 0x2000,
},
{
"path": "firmware/partition-table.bin",
"offset": 0x8000,
},
{
"path": "firmware/pancake-esp32c5.bin",
"offset": 0x10000,
}
],
}
],
}
Path("ESP32C5/docs/manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
PY
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ESP32C5/docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
discord:
name: Discord
needs: [release, package, pages]
# Temporary hard-disable. Re-enable by restoring the previous condition.
if: ${{ false }}
runs-on: ubuntu-24.04
steps:
- name: Notify Discord
env:
DISCORD_WEBHOOK: ${{ secrets.GIT_BUILD }}
FW_VERSION: ${{ needs.package.outputs.fw_version }}
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag || format('v{0}', needs.package.outputs.fw_version) }}
REPO: ${{ github.repository }}
PAGES_URL: ${{ needs.pages.outputs.page_url }}
shell: bash
run: |
set -euo pipefail
if [ -z "${DISCORD_WEBHOOK:-}" ]; then
echo "DISCORD_WEBHOOK not configured, skipping notification"
exit 0
fi
TAG="${RELEASE_TAG:-v${FW_VERSION}}"
BASE_URL="https://github.com/${REPO}/releases/download/${TAG}"
RELEASE_PAGE="https://github.com/${REPO}/releases/tag/${TAG}"
PAGE_LINK="${PAGES_URL:-https://${GITHUB_REPOSITORY%/*}.github.io/${GITHUB_REPOSITORY#*/}/}"
content=$(
printf '%s\n' \
"pancake ESP32-C5" \
"Release ${TAG} published." \
"Release page:" \
"${RELEASE_PAGE}" \
"Pages:" \
"${PAGE_LINK}" \
"Firmware (${FW_VERSION}):" \
"${BASE_URL}/${FW_BASENAME}-${FW_VERSION}.bin" \
"Full image:" \
"${BASE_URL}/${FW_BASENAME}-full-${FW_VERSION}.bin" \
"ZIP bundle:" \
"${BASE_URL}/${FW_BASENAME}-${FW_VERSION}.zip"
)
payload=$(jq -n --arg content "$content" '{content:$content}')
curl -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK"