Skip to content

Merge pull request #23 from jrowny/new-website #19

Merge pull request #23 from jrowny/new-website

Merge pull request #23 from jrowny/new-website #19

Workflow file for this run

name: Build on Tag
on:
push:
tags:
- "v*" # Triggers on tags like v1.0.0, v2.1.3, etc.
permissions:
contents: write
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- environment: esp32-build
chip_family: ESP32
artifact_prefix: esp32
- environment: esp32-s3-build
chip_family: ESP32-S3
artifact_prefix: esp32s3
- environment: seeed_xiao_esp32s-build
chip_family: ESP32-S3
artifact_prefix: seeed_xiao_esp32s3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Get version from tag
id: get_version
run: |
# Remove 'v' prefix if present and get version
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Build web assets
run: |
cd webui
npm install
npm run build
- name: Build firmware for ${{ matrix.chip_family }}
run: |
export FIRMWARE_VERSION="${{ steps.get_version.outputs.version }}"
export CHIP_FAMILY="${{ matrix.chip_family }}"
pio run -e ${{ matrix.environment }}
# Create artifacts directory and copy firmware
mkdir -p artifacts
cp .pio/build/${{ matrix.environment }}/firmware_merged.bin artifacts/${{ matrix.artifact_prefix }}-${{ steps.get_version.outputs.version }}-full.bin
cp .pio/build/${{ matrix.environment }}/firmware.bin artifacts/${{ matrix.artifact_prefix }}-${{ steps.get_version.outputs.version }}-firmware.bin
cp .pio/build/${{ matrix.environment }}/littlefs.bin artifacts/${{ matrix.artifact_prefix }}-${{ steps.get_version.outputs.version }}-filesystem.bin
- name: Create matrix info for manifest
run: |
mkdir -p matrix-info
cat > matrix-info/build-info.json << EOF
{
"environment": "${{ matrix.environment }}",
"chip_family": "${{ matrix.chip_family }}",
"artifact_prefix": "${{ matrix.artifact_prefix }}"
}
EOF
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.artifact_prefix }}-${{ steps.get_version.outputs.version }}
path: artifacts/
- name: Upload matrix info
uses: actions/upload-artifact@v4
with:
name: matrix-info-${{ matrix.artifact_prefix }}
path: matrix-info/
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get version from tag
id: get_version
run: |
# Remove 'v' prefix if present and get version
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: downloaded-artifacts
- name: Collect all firmware files
run: |
mkdir -p artifacts
find downloaded-artifacts -name "*.bin" -exec cp {} artifacts/ \;
ls -la artifacts/
- name: Generate dynamic manifest.json
run: |
# Collect matrix info from all builds
echo "Collecting matrix information..."
# Start building the manifest
cat > artifacts/manifest.json << 'EOF'
{
"name": "ESP SFS",
"version": "${{ steps.get_version.outputs.version }}",
"new_install_prompt_erase": true,
"builds": [
EOF
# Process each matrix info file
first_entry=true
for matrix_dir in downloaded-artifacts/matrix-info-*/; do
if [ -d "$matrix_dir" ]; then
echo "Processing matrix info from: $matrix_dir"
# Read matrix info
chip_family=$(jq -r '.chip_family' "$matrix_dir/build-info.json")
artifact_prefix=$(jq -r '.artifact_prefix' "$matrix_dir/build-info.json")
echo "Found build: $artifact_prefix for $chip_family"
# Add comma for subsequent entries
if [ "$first_entry" = false ]; then
echo "," >> artifacts/manifest.json
fi
first_entry=false
# Add build entry to manifest
cat >> artifacts/manifest.json << EOF
{
"chipFamily": "$chip_family",
"parts": [
{ "path": "${artifact_prefix}-${{ steps.get_version.outputs.version }}-full.bin", "offset": 0 }
]
}
EOF
fi
done
# Close the manifest
cat >> artifacts/manifest.json << 'EOF'
]
}
EOF
echo "Generated manifest.json:"
cat artifacts/manifest.json
- name: Setup Node
uses: actions/setup-node@v4
- name: Create GitHub Pages site
run: |
# Build the Vite project
cd website
npm install
npm run build
cd ..
# Copy the built Vite project to pages directory
mkdir -p pages
cp -r website/dist/* pages/
- name: Setup Pages
uses: actions/configure-pages@v4
with:
enablement: true
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Upload final artifacts
uses: actions/upload-artifact@v4
with:
name: firmware-${{ steps.get_version.outputs.version }}
path: artifacts/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}