From 9f2d533eb21696a8d3a2a4f5ff7431893955eda8 Mon Sep 17 00:00:00 2001 From: Zoria <50277488+THZoria@users.noreply.github.com> Date: Tue, 17 Mar 2026 06:52:05 +0100 Subject: [PATCH] Refactor firmware extraction and version handling --- .github/workflows/firmware-autodl.yml | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/firmware-autodl.yml b/.github/workflows/firmware-autodl.yml index 2b39d5d..599690d 100644 --- a/.github/workflows/firmware-autodl.yml +++ b/.github/workflows/firmware-autodl.yml @@ -46,38 +46,32 @@ jobs: exit 0 fi - # Extraire description Switch (ignore Switch 2) - DESCRIPTION=$(echo "$RSS" | grep -oE 'Switch [0-9]+\.[0-9]+\.[0-9]+' | \ - grep -v 'Switch 2' | \ - head -n 1) + # đŸ”„ Extraction propre de toutes les versions Switch (ignore Switch 2) + VERSIONS=$(echo "$RSS" | grep -oE 'Switch [0-9]+\.[0-9]+\.[0-9]+' | \ + grep -v 'Switch 2' | \ + grep -oE '[0-9]+\.[0-9]+\.[0-9]+') - if [ -z "$DESCRIPTION" ]; then - echo "INFO: Aucun firmware Switch valide trouvĂ©." + if [ -z "$VERSIONS" ]; then + echo "INFO: Aucun firmware trouvĂ©." echo "new_version=false" >> $GITHUB_OUTPUT exit 0 fi - echo "Description dĂ©tectĂ©e : $DESCRIPTION" + # đŸ”„ Prend la version la plus rĂ©cente (corrige ton bug) + VERSION=$(printf "%s\n" $VERSIONS | sort -V | tail -n 1) - VERSION=$(echo "$DESCRIPTION" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') - - if [ -z "$VERSION" ]; then - echo "INFO: Impossible d'extraire la version." - echo "new_version=false" >> $GITHUB_OUTPUT - exit 0 - fi + echo "Version la plus rĂ©cente dĂ©tectĂ©e : $VERSION" MAJOR=$(echo "$VERSION" | cut -d. -f1) - # Autorise uniquement 21+ + # 🔒 Ignore < 21.x if [ "$MAJOR" -lt 21 ]; then echo "INFO: Firmware $VERSION ignorĂ© (<21.x)." echo "new_version=false" >> $GITHUB_OUTPUT exit 0 fi - echo "Version valide dĂ©tectĂ©e : $VERSION" - + # 🔎 VĂ©rifie si release dĂ©jĂ  existante HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/${{ github.repository }}/releases/tags/$VERSION")