0
0
镜像自地址 https://github.com/THZoria/NX_Firmware.git 已同步 2026-04-09 10:41:13 +00:00

Improve firmware download workflow and messages

Refactor firmware download workflow for clarity and accuracy.
这个提交包含在:
Zoria
2026-03-17 07:06:25 +01:00
提交者 GitHub
父节点 a3b5ff8eea
当前提交 df02467cdd

查看文件

@@ -28,12 +28,11 @@ jobs:
- name: ⬇️ Setup hactool-linux - name: ⬇️ Setup hactool-linux
run: | run: |
# Vérifie si le fichier existe avant de tenter de le copier
if [ -f "hactool-linux" ]; then if [ -f "hactool-linux" ]; then
cp hactool-linux hactool cp hactool-linux hactool
chmod +x hactool chmod +x hactool
else else
echo "Warning: hactool-linux non trouvé dans le dépôt." echo "Warning: hactool-linux non trouvé."
fi fi
- name: 🔍 Check firmware version (Switch 1 only, >=21.0.0 strict) - name: 🔍 Check firmware version (Switch 1 only, >=21.0.0 strict)
@@ -50,83 +49,75 @@ jobs:
exit 0 exit 0
fi fi
# Extraction et tri : # LOGIQUE DE DÉTECTION ROBUSTE :
# 1. On cherche les balises Switch (ignore Switch 2) # 1. On extrait les blocs <item> pour ne pas mélanger les données
# 2. On extrait uniquement les numéros de version # 2. On filtre uniquement ceux qui contiennent 'sys=hac' (Switch 1)
# 3. On trie par ordre de version (sort -V) pour mettre la plus haute en dernier # 3. On extrait le numéro de version X.X.X
VERSIONS=$(echo "$RSS" | grep -oE '<description>Switch [0-9]+\.[0-9]+\.[0-9]+' | \ # 4. On trie par version (sort -V) et on prend la plus haute
grep -v 'Switch 2' | \
grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | \ LATEST_VERSION=$(echo "$RSS" | tr -d '\n' | sed 's/<item>/\n<item>/g' | \
sort -V) grep 'sys=hac' | \
grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | \
# On récupère la version la plus élevée de la liste sort -V | tail -n 1)
LATEST_VERSION=$(echo "$VERSIONS" | tail -n 1)
if [ -z "$LATEST_VERSION" ]; then if [ -z "$LATEST_VERSION" ]; then
echo "INFO: Aucun firmware valide trouvé." echo "INFO: Aucun firmware Switch 1 trouvé."
echo "new_version=false" >> $GITHUB_OUTPUT echo "new_version=false" >> $GITHUB_OUTPUT
exit 0 exit 0
fi fi
echo "Dernière version trouvée sur NinUpdates : $LATEST_VERSION" echo "Dernière version Switch 1 détectée : $LATEST_VERSION"
# Vérification du numéro de version majeure (>= 21) # Vérification du seuil (>= 21)
MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1) MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1)
if [ "$MAJOR" -lt 21 ]; then if [ "$MAJOR" -lt 21 ]; then
echo "INFO: Firmware $LATEST_VERSION ignoré (inférieur à 21.0.0)." echo "INFO: Version $LATEST_VERSION ignorée (seuil < 21)."
echo "new_version=false" >> $GITHUB_OUTPUT echo "new_version=false" >> $GITHUB_OUTPUT
exit 0 exit 0
fi fi
# Vérification si la Release existe déjà sur votre GitHub # Vérification si la release existe déjà
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION") "https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION")
if [ "$HTTP_STATUS" = "200" ]; then if [ "$HTTP_STATUS" = "200" ]; then
echo "INFO: La version $LATEST_VERSION a déjà été publiée." echo "INFO: La release $LATEST_VERSION existe déjà."
echo "new_version=false" >> $GITHUB_OUTPUT echo "new_version=false" >> $GITHUB_OUTPUT
else else
echo "ACTION: Nouvelle version $LATEST_VERSION détectée !" echo "ACTION: Nouvelle version $LATEST_VERSION détectée !"
echo "new_version=true" >> $GITHUB_OUTPUT echo "new_version=true" >> $GITHUB_OUTPUT
echo "firmware_version=$LATEST_VERSION" >> $GITHUB_OUTPUT echo "firmware_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
fi fi
set -e set -e
- name: 💻 Execute download script and capture changelog - name: 💻 Execute download script and capture changelog
id: download id: download
if: steps.version_check.outputs.new_version == 'true' if: steps.version_check.outputs.new_version == 'true'
run: | run: |
# On lance le script Python et on enregistre la sortie
python3 firmware_downloader.py | tee firmware_output.txt python3 firmware_downloader.py | tee firmware_output.txt
# On tente d'extraire la version confirmée par le script Python # Extraction de la version confirmée par le script (nettoyage des retours chariot)
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}' | tr -d '\r') F_VER=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}' | tr -d '\r')
# Si le script Python n'a pas renvoyé de dossier, on utilise la version du RSS if [ -z "$F_VER" ]; then
if [ -z "$FIRMWARE_VERSION" ]; then F_VER="${{ steps.version_check.outputs.firmware_version }}"
FIRMWARE_VERSION="${{ steps.version_check.outputs.firmware_version }}"
fi fi
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT echo "firmware_version=$F_VER" >> $GITHUB_OUTPUT
# Capture les dernières lignes pour le changelog de la release
tail -n 10 firmware_output.txt > changelog_body.txt tail -n 10 firmware_output.txt > changelog_body.txt
- name: 🧹 Clean and zip firmware - name: 🧹 Clean and zip firmware
if: steps.version_check.outputs.new_version == 'true' if: steps.version_check.outputs.new_version == 'true'
run: | run: |
VERSION="${{ steps.download.outputs.firmware_version }}" VERSION="${{ steps.download.outputs.firmware_version }}"
# Nettoyage des fichiers temporaires .nca split
find . -type f -name "*.nca.*" -delete find . -type f -name "*.nca.*" -delete
# Création de l'archive ZIP si le dossier existe
if [ -d "Firmware $VERSION" ]; then if [ -d "Firmware $VERSION" ]; then
rm -f "Firmware $VERSION.zip" rm -f "Firmware $VERSION.zip"
zip -rj "Firmware $VERSION.zip" "Firmware $VERSION/" -i "*.nca" zip -rj "Firmware $VERSION.zip" "Firmware $VERSION/" -i "*.nca"
else else
echo "ERROR: Le dossier 'Firmware $VERSION' est introuvable." echo "ERROR: Dossier Firmware $VERSION introuvable."
exit 1 exit 1
fi fi
@@ -137,10 +128,10 @@ jobs:
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
let body = "Automatic download of the official Nintendo Switch firmware."; let body = "Automatic download of official Nintendo Switch firmware.";
if (fs.existsSync('changelog_body.txt')) { if (fs.existsSync('changelog_body.txt')) {
const changelog = fs.readFileSync('changelog_body.txt', 'utf8'); const changelog = fs.readFileSync('changelog_body.txt', 'utf8');
body += "\n\n**Details:**\n```\n" + changelog + "\n```"; body += "\n\n**Changelog / Output:**\n```\n" + changelog + "\n```";
} }
core.setOutput('release_body', body); core.setOutput('release_body', body);