镜像自地址
https://github.com/THZoria/NX_Firmware.git
已同步 2026-04-09 10:41:13 +00:00
Update firmware auto downloader workflow to v21.0.0
Updated the firmware auto downloader workflow to include version 21.0.0, added new dependencies, and improved error handling.
这个提交包含在:
98
.github/workflows/firmware-autodl.yml
vendored
98
.github/workflows/firmware-autodl.yml
vendored
@@ -1,9 +1,9 @@
|
|||||||
name: 🎮 Firmware Auto Downloader
|
name: 🎮 Firmware Auto Downloader (21.0.0+)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 * * * *'
|
- cron: '0 * * * *' # Vérifie toutes les heures
|
||||||
workflow_dispatch:
|
workflow_dispatch: # Permet de lancer manuellement depuis l'onglet Actions
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
download_and_release:
|
download_and_release:
|
||||||
@@ -17,39 +17,47 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: 🐍 Setup Python and dependencies
|
- name: 🐍 Setup Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: ⚙️ Install required Python modules
|
- name: ⚙️ Install required Python modules
|
||||||
run: |
|
run: |
|
||||||
pip install requests anynet beautifulsoup4
|
pip install requests anynet beautifulsoup4 pycryptodome
|
||||||
|
|
||||||
- name: ⬇️ Setup hactool-linux
|
- name: ⬇️ Setup hactool-linux
|
||||||
run: |
|
run: |
|
||||||
cp hactool-linux hactool
|
if [ -f "hactool-linux" ]; then
|
||||||
|
cp hactool-linux hactool
|
||||||
|
else
|
||||||
|
echo "ERREUR: hactool-linux absent du dépôt"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
chmod +x hactool
|
chmod +x hactool
|
||||||
|
|
||||||
- name: 🔍 Check firmware version (Switch 1 only, 21.0.0+)
|
- name: 🔍 Check firmware version (Filter: 21.0.0+)
|
||||||
id: version_check
|
id: version_check
|
||||||
run: |
|
run: |
|
||||||
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | \
|
# 1. Récupérer le flux RSS de NinUpdates
|
||||||
grep '<title>Switch ' | \
|
RSS_FEED=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php')
|
||||||
grep -v '<title>Switch 2 ' | \
|
|
||||||
grep -E 'Switch ([2-9][1-9]|[3-9][0-9])\.' | \
|
# 2. Extraire la version en ignorant explicitement 19.x et 20.x
|
||||||
head -n 1)
|
# La regex '^([2-9][1-9]|[3-9][0-9])' impose un nombre >= 21
|
||||||
|
LATEST_VERSION=$(echo "$RSS_FEED" | \
|
||||||
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
|
grep -oP '<title>Switch \K[0-9.]+' | \
|
||||||
|
grep -E '^([2-9][1-9]|[3-9][0-9])\.' | \
|
||||||
|
head -n 1)
|
||||||
|
|
||||||
if [ -z "$LATEST_VERSION" ]; then
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
echo "INFO: Aucune version récente (>= 21.x) trouvée."
|
echo "INFO: Aucune nouvelle version majeure (>= 21.0.0) détectée."
|
||||||
echo "new_version=false" >> $GITHUB_OUTPUT
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Version détectée : $LATEST_VERSION"
|
echo "Version majeure détectée : $LATEST_VERSION"
|
||||||
|
|
||||||
|
# 3. Vérifier si cette version a déjà été publiée dans tes Releases
|
||||||
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")
|
||||||
@@ -58,58 +66,56 @@ jobs:
|
|||||||
echo "INFO: La release $LATEST_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 $LATEST_VERSION détectée !"
|
echo "INFO: NOUVELLE VERSION $LATEST_VERSION DETECTEE !"
|
||||||
echo "new_version=true" >> $GITHUB_OUTPUT
|
echo "new_version=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "latest_v=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: 💻 Execute download script and capture changelog
|
- name: 💻 Execute download script
|
||||||
id: download
|
id: download
|
||||||
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
|
# On lance le script avec la version détectée
|
||||||
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}')
|
python3 firmware_downloader.py "${{ steps.version_check.outputs.latest_v }}" | tee firmware_output.txt
|
||||||
|
|
||||||
|
# On récupère le nom exact du dossier créé
|
||||||
|
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}' || echo "${{ steps.version_check.outputs.latest_v }}")
|
||||||
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT
|
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT
|
||||||
tail -n 4 firmware_output.txt > changelog_body.txt
|
|
||||||
|
# Extraction d'un mini log pour la description de la release
|
||||||
|
tail -n 15 firmware_output.txt > changelog_body.txt
|
||||||
|
|
||||||
- name: 🧹 Clean .nca files
|
- name: 🧹 Zip Firmware
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
find . -type f -name "*.nca.*" -delete
|
|
||||||
VERSION="${{ steps.download.outputs.firmware_version }}"
|
VERSION="${{ steps.download.outputs.firmware_version }}"
|
||||||
if [ -d "Firmware $VERSION" ]; then
|
# Trouve le dossier (ex: "Firmware 21.0.0")
|
||||||
rm -f "Firmware $VERSION.zip"
|
DIR_NAME=$(ls -d Firmware*${VERSION}* | head -n 1)
|
||||||
zip -rj "Firmware $VERSION.zip" "Firmware $VERSION/" -i "*.nca"
|
|
||||||
|
if [ -d "$DIR_NAME" ]; then
|
||||||
|
zip -rj "Firmware_$VERSION.zip" "$DIR_NAME/"
|
||||||
|
else
|
||||||
|
echo "ERREUR: Dossier $DIR_NAME introuvable après téléchargement"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 📝 Prepare Release Body
|
- name: 📦 Create Release on GitHub
|
||||||
id: prepare_body
|
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const fs = require('fs');
|
|
||||||
if (fs.existsSync('changelog_body.txt')) {
|
|
||||||
const changelogBody = fs.readFileSync('changelog_body.txt', 'utf8');
|
|
||||||
core.setOutput('release_body', changelogBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: 📦 Create Tag and Release
|
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
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: |
|
||||||
Automatic download of the official Nintendo Switch firmware version **${{ steps.download.outputs.firmware_version }}**.
|
## 🎮 Nintendo Switch Firmware ${{ steps.download.outputs.firmware_version }}
|
||||||
|
|
||||||
---
|
Ce firmware a été automatiquement détecté et téléchargé depuis les serveurs officiels de Nintendo.
|
||||||
|
|
||||||
**Downloaded file details:**
|
|
||||||
|
|
||||||
${{ steps.prepare_body.outputs.release_body }}
|
|
||||||
|
|
||||||
|
**Détails du téléchargement :**
|
||||||
|
```text
|
||||||
|
$(cat changelog_body.txt)
|
||||||
|
```
|
||||||
files: |
|
files: |
|
||||||
Firmware ${{ steps.download.outputs.firmware_version }}.zip
|
Firmware_${{ steps.download.outputs.firmware_version }}.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户