Filaman/.github/workflows/providers/gitea-release.yml

100 lines
2.9 KiB
YAML
Raw Normal View History

name: Gitea Release
on:
workflow_call:
secrets:
GITEA_TOKEN:
required: true
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-venv build-essential curl git
- name: Set up Python Virtual Environment
run: |
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install platformio esptool
echo "Verifying installations:"
platformio --version
python3 --version
esptool.py version
- name: Build Firmware
run: |
source venv/bin/activate
echo "Building SPIFFS..."
platformio run -t buildfs
echo "Building firmware..."
platformio run
- name: Create Release Files
run: |
source venv/bin/activate
echo "Creating release files..."
esptool.py --chip esp32 merge_bin \
--flash_mode dio \
--flash_freq 40m \
--flash_size 4MB \
-o .pio/build/esp32dev/filaman_full.bin \
0x1000 .pio/build/esp32dev/bootloader.bin \
0x8000 .pio/build/esp32dev/partitions.bin \
0x10000 .pio/build/esp32dev/firmware.bin \
0x290000 .pio/build/esp32dev/spiffs.bin
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_ota.bin
- name: Create Release
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
TAG="${GITEA_REF_NAME}"
API_URL="${GITEA_SERVER_URL}/api/v1"
REPO="${GITEA_REPOSITORY}"
echo "Debug environment:"
echo "TAG: ${TAG}"
echo "API_URL: ${API_URL}"
echo "REPO: ${REPO}"
echo "Creating release for ${TAG} on ${REPO}..."
# Create release
RESPONSE=$(curl -k -s \
-X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\"}" \
"${API_URL}/repos/${REPO}/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1)
if [ -n "$RELEASE_ID" ]; then
echo "Release created with ID: $RELEASE_ID"
# Upload files
for file in "filaman_full.bin" "filaman_ota.bin"; do
echo "Uploading $file..."
curl -k -s \
-X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@.pio/build/esp32dev/$file" \
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
done
else
echo "Failed to create release. Response:"
echo "$RESPONSE"
exit 1
fi