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

比较提交

..

5 次代码提交

作者 SHA1 备注 提交日期
Zoria
df02467cdd Improve firmware download workflow and messages
Refactor firmware download workflow for clarity and accuracy.
2026-03-17 07:06:25 +01:00
Zoria
a3b5ff8eea Refactor firmware autodl workflow for improved checks 2026-03-17 07:04:25 +01:00
Zoria
bf849d454d Add lxml to Python module installation 2026-03-17 07:01:41 +01:00
Zoria
e5cac716b8 Refactor firmware autodl workflow for better handling
Updated the firmware autodl workflow to improve Python script and file handling.
2026-03-17 07:00:35 +01:00
Zoria
9f2d533eb2 Refactor firmware extraction and version handling 2026-03-17 06:52:05 +01:00

查看文件

@@ -28,8 +28,12 @@ jobs:
- name: ⬇️ Setup hactool-linux - name: ⬇️ Setup hactool-linux
run: | run: |
cp hactool-linux hactool if [ -f "hactool-linux" ]; then
chmod +x hactool cp hactool-linux hactool
chmod +x hactool
else
echo "Warning: hactool-linux non trouvé."
fi
- name: 🔍 Check firmware version (Switch 1 only, >=21.0.0 strict) - name: 🔍 Check firmware version (Switch 1 only, >=21.0.0 strict)
id: version_check id: version_check
@@ -37,60 +41,54 @@ jobs:
run: | run: |
set +e set +e
# Récupération du flux RSS
RSS=$(curl -sL --fail https://yls8.mtheall.com/ninupdates/feed.php) RSS=$(curl -sL --fail https://yls8.mtheall.com/ninupdates/feed.php)
CURL_STATUS=$? if [ $? -ne 0 ] || [ -z "$RSS" ]; then
echo "ERROR: Impossible de récupérer le flux RSS."
if [ $CURL_STATUS -ne 0 ] || [ -z "$RSS" ]; then
echo "INFO: Impossible de récupérer le RSS."
echo "new_version=false" >> $GITHUB_OUTPUT echo "new_version=false" >> $GITHUB_OUTPUT
exit 0 exit 0
fi fi
# Extraire description Switch (ignore Switch 2) # LOGIQUE DE DÉTECTION ROBUSTE :
DESCRIPTION=$(echo "$RSS" | grep -oE '<description>Switch [0-9]+\.[0-9]+\.[0-9]+' | \ # 1. On extrait les blocs <item> pour ne pas mélanger les données
grep -v 'Switch 2' | \ # 2. On filtre uniquement ceux qui contiennent 'sys=hac' (Switch 1)
head -n 1) # 3. On extrait le numéro de version X.X.X
# 4. On trie par version (sort -V) et on prend la plus haute
if [ -z "$DESCRIPTION" ]; then LATEST_VERSION=$(echo "$RSS" | tr -d '\n' | sed 's/<item>/\n<item>/g' | \
echo "INFO: Aucun firmware Switch valide trouvé." grep 'sys=hac' | \
grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | \
sort -V | tail -n 1)
if [ -z "$LATEST_VERSION" ]; then
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 "Description détectée : $DESCRIPTION" echo "Dernière version Switch 1 détectée : $LATEST_VERSION"
VERSION=$(echo "$DESCRIPTION" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') # Vérification du seuil (>= 21)
MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1)
if [ -z "$VERSION" ]; then
echo "INFO: Impossible d'extraire la version."
echo "new_version=false" >> $GITHUB_OUTPUT
exit 0
fi
MAJOR=$(echo "$VERSION" | cut -d. -f1)
# Autorise uniquement 21+
if [ "$MAJOR" -lt 21 ]; then if [ "$MAJOR" -lt 21 ]; then
echo "INFO: Firmware $VERSION ignoré (<21.x)." 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
echo "Version valide détectée : $VERSION" # 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/$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 release $VERSION existe déjà." echo "INFO: La release $LATEST_VERSION existe déjà."
echo "new_version=false" >> $GITHUB_OUTPUT echo "new_version=false" >> $GITHUB_OUTPUT
else else
echo "INFO: Nouvelle version $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=$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
@@ -98,20 +96,29 @@ jobs:
if: steps.version_check.outputs.new_version == 'true' if: steps.version_check.outputs.new_version == 'true'
run: | run: |
python3 firmware_downloader.py | tee firmware_output.txt python3 firmware_downloader.py | tee firmware_output.txt
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}')
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT # Extraction de la version confirmée par le script (nettoyage des retours chariot)
tail -n 4 firmware_output.txt > changelog_body.txt F_VER=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}' | tr -d '\r')
if [ -z "$F_VER" ]; then
F_VER="${{ steps.version_check.outputs.firmware_version }}"
fi
echo "firmware_version=$F_VER" >> $GITHUB_OUTPUT
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 }}"
find . -type f -name "*.nca.*" -delete find . -type f -name "*.nca.*" -delete
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
echo "ERROR: Dossier Firmware $VERSION introuvable."
exit 1
fi fi
- name: 📝 Prepare Release Body - name: 📝 Prepare Release Body
@@ -121,12 +128,12 @@ jobs:
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
let body = "Automatic download of official Nintendo Switch firmware.";
if (fs.existsSync('changelog_body.txt')) { if (fs.existsSync('changelog_body.txt')) {
const changelogBody = fs.readFileSync('changelog_body.txt', 'utf8'); const changelog = fs.readFileSync('changelog_body.txt', 'utf8');
core.setOutput('release_body', changelogBody); body += "\n\n**Changelog / Output:**\n```\n" + changelog + "\n```";
} else {
core.setOutput('release_body', 'No changelog available.');
} }
core.setOutput('release_body', body);
- name: 📦 Create Tag and Release - name: 📦 Create Tag and Release
if: steps.version_check.outputs.new_version == 'true' if: steps.version_check.outputs.new_version == 'true'
@@ -134,14 +141,7 @@ jobs:
with: with:
tag_name: ${{ steps.download.outputs.firmware_version }} tag_name: ${{ steps.download.outputs.firmware_version }}
name: Firmware ${{ steps.download.outputs.firmware_version }} name: Firmware ${{ steps.download.outputs.firmware_version }}
body: | body: ${{ steps.prepare_body.outputs.release_body }}
Automatic download of the official Nintendo Switch firmware version **${{ steps.download.outputs.firmware_version }}**.
---
**Downloaded file details:**
${{ steps.prepare_body.outputs.release_body }}
files: | files: |
Firmware ${{ steps.download.outputs.firmware_version }}.zip Firmware ${{ steps.download.outputs.firmware_version }}.zip
env: env: