Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6190cf04db | |||
680aed0e10 | |||
fadb122d28 | |||
4347f89c16 |
268
.github/workflows/providers/gitea-release.yml
vendored
268
.github/workflows/providers/gitea-release.yml
vendored
@ -2,36 +2,97 @@ name: Gitea Release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
server_url:
|
||||||
|
description: 'Gitea server URL'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: 'https://gitea.your-domain.com'
|
||||||
|
secrets:
|
||||||
|
GITEA_TOKEN:
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
environment: production
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.9'
|
||||||
|
|
||||||
- name: Install PlatformIO
|
- name: Install Build Dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
echo "Current directory: $(pwd)"
|
||||||
pip install --upgrade platformio
|
|
||||||
|
|
||||||
- name: Build Firmware
|
|
||||||
run: |
|
|
||||||
pio run -t buildfs # Build SPIFFS
|
|
||||||
pio run # Build firmware
|
|
||||||
|
|
||||||
- name: Install esptool
|
# Systemabhängigkeiten
|
||||||
run: |
|
sudo apt-get update
|
||||||
pip install esptool
|
sudo apt-get install -y build-essential gcc git wget
|
||||||
|
|
||||||
- name: Merge firmware and SPIFFS
|
# PlatformIO CLI installieren
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/get-platformio.py -o get-platformio.py
|
||||||
|
python3 get-platformio.py
|
||||||
|
|
||||||
|
# PATH aktualisieren
|
||||||
|
echo "$HOME/.platformio/penv/bin" >> $GITHUB_PATH
|
||||||
|
export PATH="$HOME/.platformio/penv/bin:$PATH"
|
||||||
|
|
||||||
|
echo "Verifying installation:"
|
||||||
|
pio --version
|
||||||
|
python --version
|
||||||
|
gcc --version
|
||||||
|
|
||||||
|
echo "Project contents:"
|
||||||
|
ls -la
|
||||||
|
|
||||||
|
- name: Prepare Build Environment
|
||||||
run: |
|
run: |
|
||||||
|
# PlatformIO Core initialisieren
|
||||||
|
pio platform install "espressif32"
|
||||||
|
|
||||||
|
echo "Installing libraries..."
|
||||||
|
pio lib install \
|
||||||
|
"tzapu/WiFiManager @ ^2.0.17" \
|
||||||
|
"https://github.com/me-no-dev/ESPAsyncWebServer.git" \
|
||||||
|
"me-no-dev/AsyncTCP @ ^1.1.1" \
|
||||||
|
"bogde/HX711 @ ^0.7.5" \
|
||||||
|
"adafruit/Adafruit SSD1306 @ ^2.5.13" \
|
||||||
|
"adafruit/Adafruit GFX Library @ ^1.11.11" \
|
||||||
|
"adafruit/Adafruit PN532 @ ^1.3.3" \
|
||||||
|
"bblanchon/ArduinoJson @ ^7.3.0" \
|
||||||
|
"knolleary/PubSubClient @ ^2.8" \
|
||||||
|
"digitaldragon/SSLClient @ ^1.3.2"
|
||||||
|
|
||||||
|
echo "Installed libraries:"
|
||||||
|
pio lib list
|
||||||
|
|
||||||
|
- name: Build Project
|
||||||
|
run: |
|
||||||
|
# PlatformIO Core Variablen setzen
|
||||||
|
export PLATFORMIO_BUILD_FLAGS="-D VERSION=\\"1.2.35\\" -DNDEBUG"
|
||||||
|
|
||||||
|
echo "Building project..."
|
||||||
|
pio run -e esp32dev -v
|
||||||
|
|
||||||
|
echo "Building SPIFFS..."
|
||||||
|
pio run -e esp32dev -t buildfs -v
|
||||||
|
|
||||||
|
echo "Build output:"
|
||||||
|
ls -la .pio/build/esp32dev/
|
||||||
|
|
||||||
|
- name: Merge Firmware Files
|
||||||
|
run: |
|
||||||
|
pip install esptool==4.5.1
|
||||||
|
|
||||||
|
echo "Available files:"
|
||||||
|
ls -la .pio/build/esp32dev/
|
||||||
|
|
||||||
esptool.py --chip esp32 merge_bin \
|
esptool.py --chip esp32 merge_bin \
|
||||||
--flash_mode dio \
|
--flash_mode dio \
|
||||||
--flash_freq 40m \
|
--flash_freq 40m \
|
||||||
@ -41,140 +102,65 @@ jobs:
|
|||||||
0x8000 .pio/build/esp32dev/partitions.bin \
|
0x8000 .pio/build/esp32dev/partitions.bin \
|
||||||
0x10000 .pio/build/esp32dev/firmware.bin \
|
0x10000 .pio/build/esp32dev/firmware.bin \
|
||||||
0x290000 .pio/build/esp32dev/spiffs.bin
|
0x290000 .pio/build/esp32dev/spiffs.bin
|
||||||
|
|
||||||
- name: Prepare OTA firmware
|
|
||||||
run: |
|
|
||||||
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_ota.bin
|
|
||||||
|
|
||||||
- name: Get version from tag
|
|
||||||
id: get_version
|
|
||||||
run: |
|
|
||||||
TAG="${GITEA_REF_NAME}"
|
|
||||||
VERSION="${TAG#v}"
|
|
||||||
echo "VERSION=$VERSION" >> $GITEA_OUTPUT
|
|
||||||
|
|
||||||
- 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" >> $GITEA_OUTPUT
|
|
||||||
echo "$CHANGELOG" >> $GITEA_OUTPUT
|
|
||||||
echo "EOF" >> $GITEA_OUTPUT
|
|
||||||
|
|
||||||
- name: Create Gitea Release
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
# Debug: Print all environment variables (excluding the token)
|
|
||||||
env | grep -v "GITEA_TOKEN"
|
|
||||||
|
|
||||||
# Remove trailing slash from server URL if present
|
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_ota.bin
|
||||||
SERVER_URL="${GITEA_SERVER_URL%/}"
|
|
||||||
|
echo "Final binaries:"
|
||||||
|
ls -la .pio/build/esp32dev/filaman_*.bin
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
SERVER_URL: ${{ inputs.server_url }}
|
||||||
|
run: |
|
||||||
|
# Basis-Variablen
|
||||||
|
API_BASE="${GITEA_SERVER_URL:-${SERVER_URL}}/api/v1"
|
||||||
REPO="${GITEA_REPOSITORY}"
|
REPO="${GITEA_REPOSITORY}"
|
||||||
TAG="${GITEA_REF_NAME}"
|
TAG="${GITEA_REF_NAME}"
|
||||||
VERSION="${TAG#v}" # Remove v prefix if present
|
|
||||||
|
|
||||||
echo "Debug environment:"
|
echo "Release configuration:"
|
||||||
echo "Server URL: $SERVER_URL"
|
echo "API Base: $API_BASE"
|
||||||
echo "Repository: $REPO"
|
echo "Repository: $REPO"
|
||||||
echo "Tag: $TAG"
|
echo "Tag: $TAG"
|
||||||
echo "Version: $VERSION"
|
|
||||||
|
|
||||||
# Test API connectivity
|
# Test API-Verbindung
|
||||||
echo "Testing API connectivity..."
|
echo "Testing API connection..."
|
||||||
TEST_RESPONSE=$(curl -v -k -H "Authorization: token ${GITEA_TOKEN}" "${SERVER_URL}/api/v1/version" 2>&1)
|
curl -k -v \
|
||||||
echo "API Test Response:"
|
-H "Authorization: token ${TOKEN}" \
|
||||||
echo "$TEST_RESPONSE"
|
"${API_BASE}/version"
|
||||||
|
|
||||||
# Construct clean API URL
|
# Release erstellen
|
||||||
API_URL="${SERVER_URL}/api/v1"
|
|
||||||
RELEASE_URL="${API_URL}/repos/${REPO}/releases"
|
|
||||||
|
|
||||||
echo "Using Release API URL: $RELEASE_URL"
|
|
||||||
|
|
||||||
# Common curl options
|
|
||||||
CURL_OPTS="-v -k" # -v for verbose, -k to ignore SSL verification
|
|
||||||
|
|
||||||
# Create release with minimal data first
|
|
||||||
echo "Creating release..."
|
echo "Creating release..."
|
||||||
RELEASE_RESPONSE=$(curl $CURL_OPTS -X POST \
|
RESPONSE=$(curl -k -v \
|
||||||
-H "accept: application/json" \
|
-X POST \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\"}" \
|
||||||
"${RELEASE_URL}" 2>&1)
|
"${API_BASE}/repos/${REPO}/releases")
|
||||||
|
|
||||||
echo "Full release creation response (including headers):"
|
echo "Release response:"
|
||||||
echo "$RELEASE_RESPONSE"
|
echo "$RESPONSE"
|
||||||
|
|
||||||
# Extract the JSON response (last line)
|
# Release ID extrahieren
|
||||||
RELEASE_JSON=$(echo "$RELEASE_RESPONSE" | tail -n 1)
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1)
|
||||||
echo "Release JSON response:"
|
|
||||||
echo "$RELEASE_JSON" | jq '.' || echo "Failed to parse JSON response"
|
|
||||||
|
|
||||||
# Get release ID
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
echo "Release created with ID: $RELEASE_ID"
|
||||||
|
|
||||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
# Binärdateien hochladen
|
||||||
echo "Failed to create release. Full response:"
|
for file in "filaman_full.bin" "filaman_ota.bin"; do
|
||||||
echo "$RELEASE_RESPONSE"
|
echo "Uploading $file..."
|
||||||
# Try to get more detailed error information
|
curl -k -v \
|
||||||
ERROR_MSG=$(echo "$RELEASE_JSON" | jq -r '.message // .error // "Unknown error"')
|
-X POST \
|
||||||
echo "Error message: $ERROR_MSG"
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@.pio/build/esp32dev/$file" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Upload completed"
|
||||||
|
else
|
||||||
|
echo "Failed to create release"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Successfully created release with ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
# Upload assets
|
|
||||||
for file in "filaman_full.bin" "filaman_ota.bin"; do
|
|
||||||
echo "Uploading $file..."
|
|
||||||
UPLOAD_URL="${RELEASE_URL}/${RELEASE_ID}/assets?name=${file}"
|
|
||||||
echo "Upload URL: $UPLOAD_URL"
|
|
||||||
|
|
||||||
UPLOAD_RESPONSE=$(curl $CURL_OPTS -X POST \
|
|
||||||
-H "accept: application/json" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@.pio/build/esp32dev/${file}" \
|
|
||||||
"${UPLOAD_URL}" 2>&1)
|
|
||||||
|
|
||||||
echo "Full upload response for $file (including headers):"
|
|
||||||
echo "$UPLOAD_RESPONSE"
|
|
||||||
|
|
||||||
# Extract the JSON response (last line)
|
|
||||||
UPLOAD_JSON=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
|
|
||||||
echo "Upload JSON response:"
|
|
||||||
echo "$UPLOAD_JSON" | jq '.' || echo "Failed to parse JSON response"
|
|
||||||
|
|
||||||
if ! echo "$UPLOAD_JSON" | jq -e '.id' > /dev/null; then
|
|
||||||
echo "Failed to upload $file. Full response:"
|
|
||||||
echo "$UPLOAD_RESPONSE"
|
|
||||||
ERROR_MSG=$(echo "$UPLOAD_JSON" | jq -r '.message // .error // "Unknown error"')
|
|
||||||
echo "Error message: $ERROR_MSG"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Successfully uploaded $file"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Update release with full description after successful file upload
|
|
||||||
echo "Updating release description..."
|
|
||||||
CHANGELOG='${{ steps.changelog.outputs.CHANGES }}'
|
|
||||||
UPDATE_RESPONSE=$(curl $CURL_OPTS -X PATCH \
|
|
||||||
-H "accept: application/json" \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"body\":$(echo "$CHANGELOG" | jq -R -s .)}" \
|
|
||||||
"${RELEASE_URL}/${RELEASE_ID}" 2>&1)
|
|
||||||
|
|
||||||
echo "Full update response (including headers):"
|
|
||||||
echo "$UPDATE_RESPONSE"
|
|
||||||
|
|
||||||
# Extract the JSON response (last line)
|
|
||||||
UPDATE_JSON=$(echo "$UPDATE_RESPONSE" | tail -n 1)
|
|
||||||
echo "Update JSON response:"
|
|
||||||
echo "$UPDATE_JSON" | jq '.' || echo "Failed to parse JSON response"
|
|
||||||
|
|
||||||
echo "Release process completed"
|
|
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
@ -10,6 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
provider: ${{ steps.provider.outputs.provider }}
|
provider: ${{ steps.provider.outputs.provider }}
|
||||||
|
server_url: ${{ steps.provider.outputs.server_url }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -20,6 +21,7 @@ jobs:
|
|||||||
echo "GITHUB_ACTIONS=${GITHUB_ACTIONS:-not set}"
|
echo "GITHUB_ACTIONS=${GITHUB_ACTIONS:-not set}"
|
||||||
echo "GITEA_ACTIONS=${GITEA_ACTIONS:-not set}"
|
echo "GITEA_ACTIONS=${GITEA_ACTIONS:-not set}"
|
||||||
echo "GITEA_REPOSITORY=${GITEA_REPOSITORY:-not set}"
|
echo "GITEA_REPOSITORY=${GITEA_REPOSITORY:-not set}"
|
||||||
|
echo "GITEA_SERVER_URL=${GITEA_SERVER_URL:-not set}"
|
||||||
echo "RUNNER_NAME=${RUNNER_NAME:-not set}"
|
echo "RUNNER_NAME=${RUNNER_NAME:-not set}"
|
||||||
|
|
||||||
- name: Determine CI Provider
|
- name: Determine CI Provider
|
||||||
@ -28,17 +30,24 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Initialize provider as unknown
|
# Initialize provider as unknown
|
||||||
PROVIDER="unknown"
|
PROVIDER="unknown"
|
||||||
|
SERVER_URL=""
|
||||||
|
|
||||||
# Check for Gitea specific environment first
|
# Check for Gitea specific environment first
|
||||||
if [ -n "${GITEA_ACTIONS}" ] || [ -n "${GITEA_REPOSITORY}" ] || [[ "${RUNNER_NAME}" == *"gitea"* ]]; then
|
if [ -n "${GITEA_ACTIONS}" ] || [ -n "${GITEA_REPOSITORY}" ] || [[ "${RUNNER_NAME}" == *"gitea"* ]]; then
|
||||||
PROVIDER="gitea"
|
PROVIDER="gitea"
|
||||||
|
SERVER_URL="${GITEA_SERVER_URL}"
|
||||||
# Then check for GitHub
|
# Then check for GitHub
|
||||||
elif [ "${GITHUB_ACTIONS}" = "true" ]; then
|
elif [ "${GITHUB_ACTIONS}" = "true" ]; then
|
||||||
PROVIDER="github"
|
PROVIDER="github"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Detected provider: ${PROVIDER}"
|
echo "Detected provider: ${PROVIDER}"
|
||||||
echo "provider=${PROVIDER}" >> "${GITHUB_OUTPUT}"
|
echo "Server URL: ${SERVER_URL}"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "provider=${PROVIDER}"
|
||||||
|
echo "server_url=${SERVER_URL}"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
verify-provider:
|
verify-provider:
|
||||||
needs: route
|
needs: route
|
||||||
@ -47,17 +56,22 @@ jobs:
|
|||||||
- name: Echo detected provider
|
- name: Echo detected provider
|
||||||
run: |
|
run: |
|
||||||
echo "Detected CI Provider: ${{ needs.route.outputs.provider }}"
|
echo "Detected CI Provider: ${{ needs.route.outputs.provider }}"
|
||||||
|
echo "Server URL: ${{ needs.route.outputs.server_url }}"
|
||||||
if [ "${{ needs.route.outputs.provider }}" = "unknown" ]; then
|
if [ "${{ needs.route.outputs.provider }}" = "unknown" ]; then
|
||||||
echo "::error::Failed to detect CI provider!"
|
echo "::error::Failed to detect CI provider!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
github-release:
|
github-release:
|
||||||
needs: verify-provider
|
needs: [route, verify-provider]
|
||||||
if: needs.route.outputs.provider == 'github'
|
if: needs.route.outputs.provider == 'github'
|
||||||
uses: ./.github/workflows/providers/github-release.yml
|
uses: ./.github/workflows/providers/github-release.yml
|
||||||
|
|
||||||
gitea-release:
|
gitea-release:
|
||||||
needs: verify-provider
|
needs: [route, verify-provider]
|
||||||
if: needs.route.outputs.provider == 'gitea'
|
if: needs.route.outputs.provider == 'gitea'
|
||||||
uses: ./.github/workflows/providers/gitea-release.yml
|
uses: ./.github/workflows/providers/gitea-release.yml
|
||||||
|
with:
|
||||||
|
server_url: ${{ needs.route.outputs.server_url }}
|
||||||
|
secrets:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.2.36] - 2025-02-19
|
||||||
|
### Added
|
||||||
|
- update Gitea release workflow and increment version to 1.2.36
|
||||||
|
|
||||||
|
|
||||||
|
## [1.2.35] - 2025-02-19
|
||||||
|
### Added
|
||||||
|
- update Gitea release workflow and version to 1.2.35
|
||||||
|
|
||||||
|
|
||||||
## [1.2.34] - 2025-02-19
|
## [1.2.34] - 2025-02-19
|
||||||
### Added
|
### Added
|
||||||
- update version to 1.2.34 and enhance Gitea and GitHub release workflows
|
- update version to 1.2.34 and enhance Gitea and GitHub release workflows
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "1.2.34"
|
version = "1.2.36"
|
||||||
|
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
|
Reference in New Issue
Block a user