Compare commits
2 Commits
8550857711
...
8b14844ed1
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b14844ed1 | |||
| 7e739369ef |
@@ -2,18 +2,17 @@ name: Build and Package Arduino Firmware
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- '*'
|
- 'v*'
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure Safe Directory
|
- name: Configure Safe Directory
|
||||||
run: |
|
run: |
|
||||||
@@ -21,8 +20,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Set Version Identifier
|
- name: Set Version Identifier
|
||||||
run: |
|
run: |
|
||||||
git rev-parse --short HEAD > version.txt
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
echo "Build version (commit ID): $(cat version.txt)"
|
echo "$TAG" > version.txt
|
||||||
|
echo "Build version (tag): $TAG"
|
||||||
|
|
||||||
- name: Compile Arduino Sketch
|
- name: Compile Arduino Sketch
|
||||||
uses: arduino/compile-sketches@v1
|
uses: arduino/compile-sketches@v1
|
||||||
@@ -53,10 +53,53 @@ jobs:
|
|||||||
|
|
||||||
- name: Package Release
|
- name: Package Release
|
||||||
run: |
|
run: |
|
||||||
tar -czvf esp32-aldl-arduino-firmware.tar.gz -C dist .
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
tar -czvf "esp32-aldl-${TAG}.tar.gz" -C dist .
|
||||||
|
|
||||||
- name: Upload Firmware Package
|
- name: Upload Firmware Package
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: esp32-aldl-arduino-firmware-${{ github.sha }}
|
name: esp32-aldl-arduino-firmware-${{ github.sha }}
|
||||||
path: esp32-aldl-arduino-firmware.tar.gz
|
path: esp32-aldl-*.tar.gz
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Create Release and Upload Asset
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
API_URL: ${{ github.api_url }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
FILE="esp32-aldl-${TAG}.tar.gz"
|
||||||
|
NAME="${TAG}"
|
||||||
|
|
||||||
|
# 1. Create the release
|
||||||
|
RESP=$(curl -s -H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$NAME\",\"body\":\"Release $TAG\"}" \
|
||||||
|
"$API_URL/repos/$REPO/releases")
|
||||||
|
|
||||||
|
# 2. Extract upload endpoint
|
||||||
|
UPLOAD_URL=$(echo "$RESP" | jq -r '.upload_url // empty')
|
||||||
|
RELEASE_ID=$(echo "$RESP" | jq -r '.id // empty')
|
||||||
|
|
||||||
|
# 3. Upload asset
|
||||||
|
if [ -n "$UPLOAD_URL" ]; then
|
||||||
|
# GitHub style (upload_url contains {?name,label})
|
||||||
|
UPLOAD_URL="${UPLOAD_URL%\{?name,label\}}"
|
||||||
|
curl -s -H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/gzip" \
|
||||||
|
--data-binary @$FILE \
|
||||||
|
"${UPLOAD_URL}?name=${FILE}"
|
||||||
|
elif [ -n "$RELEASE_ID" ]; then
|
||||||
|
# Gitea style (POST to /releases/{id}/assets)
|
||||||
|
curl -s -H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/gzip" \
|
||||||
|
--data-binary @$FILE \
|
||||||
|
"$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=${FILE}"
|
||||||
|
else
|
||||||
|
echo "Failed to create release"
|
||||||
|
echo "$RESP"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
Reference in New Issue
Block a user