refactor: streamline Gitea and GitHub release workflows to check for data changes and update binary handling
This commit is contained in:
parent
3770de15d3
commit
262a2fcbd4
105
.github/workflows/providers/gitea-release.yml
vendored
105
.github/workflows/providers/gitea-release.yml
vendored
@ -3,9 +3,6 @@ name: Gitea Release
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
gitea_ref_name:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
gitea_server_url:
|
gitea_server_url:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
@ -48,30 +45,66 @@ jobs:
|
|||||||
echo "SPIFFS_CHANGED=false" >> $GITHUB_OUTPUT
|
echo "SPIFFS_CHANGED=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Check for Data changes
|
||||||
|
id: check_data
|
||||||
|
run: |
|
||||||
|
git fetch --unshallow || true
|
||||||
|
CHANGED_FILES=$(git diff --name-only HEAD^..HEAD)
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^data/"; then
|
||||||
|
echo "DATA_CHANGED=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "DATA_CHANGED=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Get version from platformio.ini
|
||||||
|
id: get_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
run: |
|
run: |
|
||||||
# Get version from platformio.ini
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
|
||||||
|
|
||||||
# Always build firmware
|
# Always build firmware and SPIFFS
|
||||||
|
echo "Building firmware and SPIFFS..."
|
||||||
pio run -e esp32dev
|
pio run -e esp32dev
|
||||||
|
pio run -t buildfs
|
||||||
|
|
||||||
|
# Copy firmware binary
|
||||||
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin
|
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin
|
||||||
|
|
||||||
# Only build SPIFFS if changed
|
# Create full binary (always)
|
||||||
if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then
|
(cd .pio/build/esp32dev && \
|
||||||
echo "Building SPIFFS due to changes..."
|
esptool.py --chip esp32 merge_bin \
|
||||||
pio run -t buildfs
|
--fill-flash-size 4MB \
|
||||||
|
--flash_mode dio \
|
||||||
|
--flash_freq 40m \
|
||||||
|
--flash_size 4MB \
|
||||||
|
-o filaman_full_${VERSION}.bin \
|
||||||
|
0x0000 bootloader.bin \
|
||||||
|
0x8000 partitions.bin \
|
||||||
|
0x10000 firmware.bin \
|
||||||
|
0x390000 spiffs.bin)
|
||||||
|
|
||||||
|
# Only copy SPIFFS binary if data changed
|
||||||
|
if [[ "${{ steps.check_data.outputs.DATA_CHANGED }}" == "true" ]]; then
|
||||||
|
echo "Data changes detected, copying SPIFFS binary..."
|
||||||
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin
|
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Verify file sizes
|
||||||
|
echo "File sizes:"
|
||||||
|
(cd .pio/build/esp32dev && ls -lh *.bin)
|
||||||
|
|
||||||
- name: Prepare binaries
|
- name: Prepare binaries
|
||||||
run: |
|
run: |
|
||||||
cd .pio/build/esp32dev
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
VERSION=$(grep '^version = ' ../../platformio.ini | cut -d'"' -f2)
|
|
||||||
|
|
||||||
# Create full binary only if SPIFFS changed
|
# Create full binary only if SPIFFS changed
|
||||||
if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then
|
if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then
|
||||||
echo "Creating full binary..."
|
echo "Creating full binary..."
|
||||||
|
cd .pio/build/esp32dev && \
|
||||||
esptool.py --chip esp32 merge_bin \
|
esptool.py --chip esp32 merge_bin \
|
||||||
--fill-flash-size 4MB \
|
--fill-flash-size 4MB \
|
||||||
--flash_mode dio \
|
--flash_mode dio \
|
||||||
@ -86,16 +119,24 @@ jobs:
|
|||||||
|
|
||||||
# Verify file sizes
|
# Verify file sizes
|
||||||
echo "File sizes:"
|
echo "File sizes:"
|
||||||
ls -lh *.bin
|
cd .pio/build/esp32dev && ls -lh *.bin
|
||||||
|
|
||||||
|
- name: Read CHANGELOG.md
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md)
|
||||||
|
echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ inputs.gitea_ref_name }}"
|
|
||||||
API_URL="${{ inputs.gitea_server_url }}/api/v1"
|
API_URL="${{ inputs.gitea_server_url }}/api/v1"
|
||||||
REPO="${{ inputs.gitea_repository }}"
|
REPO="${{ inputs.gitea_repository }}"
|
||||||
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
|
||||||
# Create release
|
# Create release
|
||||||
RESPONSE=$(curl -k -s \
|
RESPONSE=$(curl -k -s \
|
||||||
@ -103,8 +144,8 @@ jobs:
|
|||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\":\"${TAG}\",
|
\"tag_name\":\"v${VERSION}\",
|
||||||
\"name\":\"Release ${TAG}\",
|
\"name\":\"Release ${VERSION}\",
|
||||||
\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"
|
\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"
|
||||||
}" \
|
}" \
|
||||||
"${API_URL}/repos/${REPO}/releases")
|
"${API_URL}/repos/${REPO}/releases")
|
||||||
@ -113,30 +154,30 @@ jobs:
|
|||||||
|
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
echo "Release created with ID: $RELEASE_ID"
|
echo "Release created with ID: $RELEASE_ID"
|
||||||
cd .pio/build/esp32dev
|
|
||||||
|
|
||||||
# Always upload firmware
|
# Always upload firmware and full binary
|
||||||
if [ -f "filaman_${VERSION}.bin" ]; then
|
for file in filaman_${VERSION}.bin filaman_full_${VERSION}.bin; do
|
||||||
curl -k -s \
|
if [ -f ".pio/build/esp32dev/$file" ]; then
|
||||||
-X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@filaman_${VERSION}.bin" \
|
|
||||||
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=filaman_${VERSION}.bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload SPIFFS and full binary only if they exist
|
|
||||||
for file in webpage_${VERSION}.bin filaman_full_${VERSION}.bin; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
echo "Uploading $file..."
|
echo "Uploading $file..."
|
||||||
curl -k -s \
|
curl -k -s \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@$file" \
|
--data-binary "@.pio/build/esp32dev/$file" \
|
||||||
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Upload SPIFFS binary only if it exists (data changes)
|
||||||
|
if [ -f ".pio/build/esp32dev/webpage_${VERSION}.bin" ]; then
|
||||||
|
echo "Uploading webpage binary..."
|
||||||
|
curl -k -s \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@.pio/build/esp32dev/webpage_${VERSION}.bin" \
|
||||||
|
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=webpage_${VERSION}.bin"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Failed to create release. Response:"
|
echo "Failed to create release. Response:"
|
||||||
echo "$RESPONSE"
|
echo "$RESPONSE"
|
||||||
|
72
.github/workflows/providers/github-release.yml
vendored
72
.github/workflows/providers/github-release.yml
vendored
@ -26,61 +26,57 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install xxd
|
sudo apt-get install xxd
|
||||||
|
|
||||||
- name: Check for SPIFFS changes
|
- name: Check for Data changes
|
||||||
id: check_spiffs
|
id: check_data
|
||||||
run: |
|
run: |
|
||||||
git fetch --unshallow || true
|
git fetch --unshallow || true
|
||||||
CHANGED_FILES=$(git diff --name-only HEAD^..HEAD)
|
CHANGED_FILES=$(git diff --name-only HEAD^..HEAD)
|
||||||
if echo "$CHANGED_FILES" | grep -q "^data/\|^html/"; then
|
if echo "$CHANGED_FILES" | grep -q "^data/"; then
|
||||||
echo "SPIFFS_CHANGED=true" >> $GITHUB_OUTPUT
|
echo "DATA_CHANGED=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "SPIFFS_CHANGED=false" >> $GITHUB_OUTPUT
|
echo "DATA_CHANGED=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
run: |
|
run: |
|
||||||
# Get version from platformio.ini
|
|
||||||
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
||||||
|
|
||||||
# Always build firmware
|
# Always build firmware and SPIFFS
|
||||||
|
echo "Building firmware and SPIFFS..."
|
||||||
pio run -e esp32dev
|
pio run -e esp32dev
|
||||||
|
pio run -t buildfs
|
||||||
|
|
||||||
|
# Copy firmware binary
|
||||||
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin
|
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin
|
||||||
|
|
||||||
# Only build SPIFFS if changed
|
# Create full binary (always)
|
||||||
if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then
|
(cd .pio/build/esp32dev && \
|
||||||
echo "Building SPIFFS due to changes..."
|
esptool.py --chip esp32 merge_bin \
|
||||||
pio run -t buildfs
|
--fill-flash-size 4MB \
|
||||||
|
--flash_mode dio \
|
||||||
|
--flash_freq 40m \
|
||||||
|
--flash_size 4MB \
|
||||||
|
-o filaman_full_${VERSION}.bin \
|
||||||
|
0x0000 bootloader.bin \
|
||||||
|
0x8000 partitions.bin \
|
||||||
|
0x10000 firmware.bin \
|
||||||
|
0x390000 spiffs.bin)
|
||||||
|
|
||||||
|
# Only copy SPIFFS binary if data changed
|
||||||
|
if [[ "${{ steps.check_data.outputs.DATA_CHANGED }}" == "true" ]]; then
|
||||||
|
echo "Data changes detected, copying SPIFFS binary..."
|
||||||
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin
|
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Prepare binaries
|
|
||||||
run: |
|
|
||||||
cd .pio/build/esp32dev
|
|
||||||
VERSION=$(grep '^version = ' ../../platformio.ini | cut -d'"' -f2)
|
|
||||||
|
|
||||||
# Create full binary only if SPIFFS changed
|
|
||||||
if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then
|
|
||||||
echo "Creating full binary..."
|
|
||||||
esptool.py --chip esp32 merge_bin \
|
|
||||||
--fill-flash-size 4MB \
|
|
||||||
--flash_mode dio \
|
|
||||||
--flash_freq 40m \
|
|
||||||
--flash_size 4MB \
|
|
||||||
-o filaman_full_${VERSION}.bin \
|
|
||||||
0x0000 bootloader.bin \
|
|
||||||
0x8000 partitions.bin \
|
|
||||||
0x10000 firmware.bin \
|
|
||||||
0x390000 spiffs.bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Verify file sizes
|
# Verify file sizes
|
||||||
echo "File sizes:"
|
echo "File sizes:"
|
||||||
ls -lh *.bin
|
(cd .pio/build/esp32dev && ls -lh *.bin)
|
||||||
|
|
||||||
- name: Get version from tag
|
- name: Get version from platformio.ini
|
||||||
id: get_version
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2)
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Read CHANGELOG.md
|
- name: Read CHANGELOG.md
|
||||||
id: changelog
|
id: changelog
|
||||||
@ -95,8 +91,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
|
||||||
|
# Create release with available files
|
||||||
cd .pio/build/esp32dev
|
cd .pio/build/esp32dev
|
||||||
VERSION=$(grep '^version = ' ../../platformio.ini | cut -d'"' -f2)
|
|
||||||
FILES_TO_UPLOAD=""
|
FILES_TO_UPLOAD=""
|
||||||
|
|
||||||
# Always add firmware
|
# Always add firmware
|
||||||
@ -115,8 +113,8 @@ jobs:
|
|||||||
|
|
||||||
# Create release with available files
|
# Create release with available files
|
||||||
if [ -n "$FILES_TO_UPLOAD" ]; then
|
if [ -n "$FILES_TO_UPLOAD" ]; then
|
||||||
gh release create "${{ github.ref_name }}" \
|
gh release create "v${VERSION}" \
|
||||||
--title "Release ${{ steps.get_version.outputs.VERSION }}" \
|
--title "Release ${VERSION}" \
|
||||||
--notes "${{ steps.changelog.outputs.CHANGES }}" \
|
--notes "${{ steps.changelog.outputs.CHANGES }}" \
|
||||||
$FILES_TO_UPLOAD
|
$FILES_TO_UPLOAD
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user