Skip to content

20240421

20240421 #1

Workflow file for this run

name: Build, release, push firmware
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- '*' # Push events to matching *, any
jobs:
build_release_push:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install Node JS
uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: pip install --upgrade platformio==6.1.11
- name: Build PlatformIO Project
run: pio run
- name: Get Release Version
id: get_version
shell: bash
run: |
value=$(grep '#define VERSION' src/version.h | awk -F '"' '{print $2}')
echo "version=$value" >> $GITHUB_OUTPUT
- name: Get last commit message
id: get_commit_message
run: |
currentTag=${GITHUB_REF#refs/tags/}
badgeText="![GitHub Downloads](https://img.shields.io/github/downloads/xyzroe/XZG/${currentTag}/total)"
printf -v badgeTextWithNewlines "%s\n\n" "$badgeText"
commitMessage=$(git log -1 --pretty=%B | tail -n +2)
fullCommitMessage="${badgeTextWithNewlines}${commitMessage}"
echo "releaseMessage<<EOF" >> $GITHUB_ENV
printf "%s\n" "$fullCommitMessage" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
GITHUB_REF: ${{ github.ref }}
- name: Create manifest.json for ESP Web Tools
run: |
cat << EOF > manifest.json
{
"name": "XZG Firmware",
"version": "${{ steps.get_version.outputs.version }}",
"builds": [
{
"chipFamily": "ESP32",
"improv": false,
"parts": [
{
"path": "https://raw.githubusercontent.com/${{ github.repository }}/releases/${{ steps.get_version.outputs.version }}/XZG_${{ steps.get_version.outputs.version }}.full.bin",
"offset": 0
}
]
}
]
}
EOF
echo "Manifest file created."
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: false
name: "${{ steps.get_version.outputs.version }}"
body: ${{ env.releaseMessage }}
files: |
bin/XZG_${{ steps.get_version.outputs.version }}.ota.bin
bin/XZG_${{ steps.get_version.outputs.version }}.full.bin
- name: Checkout releases branch
uses: actions/checkout@v3
with:
ref: releases
path: releases
- name: Copy files to releases directory
run: |
mkdir -p releases/${{ steps.get_version.outputs.version }}
cp ./bin/XZG_${{ steps.get_version.outputs.version }}.full.bin releases/${{ steps.get_version.outputs.version }}/
cp manifest.json releases/${{ steps.get_version.outputs.version }}/
echo "Files copied to releases directory."
- name: Commit and push files to releases branch
run: |
cd releases
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add firmware and manifest for version ${{ steps.get_version.outputs.version }}"
git push origin releases