镜像自地址
https://github.com/THZoria/NX_Firmware.git
已同步 2026-04-09 10:41:13 +00:00
Update firmware autodl workflow for version checks
这个提交包含在:
141
.github/workflows/firmware-autodl.yml
vendored
141
.github/workflows/firmware-autodl.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: 🎮 Firmware Auto Downloader (21.0.0+)
|
name: 🎮 Firmware Auto Downloader
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -21,86 +21,123 @@ jobs:
|
|||||||
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 pycryptodome
|
pip install requests anynet beautifulsoup4
|
||||||
|
|
||||||
- name: ⬇️ Setup hactool-linux
|
- name: ⬇️ Setup hactool-linux
|
||||||
run: |
|
run: |
|
||||||
if [ -f "hactool-linux" ]; then
|
cp hactool-linux hactool
|
||||||
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 (Filter: 21.0.0+)
|
- name: 🔍 Check firmware version (Switch 1 only, >=21.0.0 strict)
|
||||||
id: version_check
|
id: version_check
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
RSS_FEED=$(curl -s https://yls8.mtheall.com/ninupdates/feed.php)
|
RSS=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php')
|
||||||
|
|
||||||
# Extraction simple sans grep -P
|
# Extraire le premier <item> Switch (pas Switch 2)
|
||||||
LATEST_VERSION=$(echo "$RSS_FEED" \
|
ITEM=$(echo "$RSS" | awk '
|
||||||
| grep "<title>Switch" \
|
/<item>/,/<\/item>/ {
|
||||||
| sed -E 's/.*Switch ([0-9.]+).*/\1/' \
|
if ($0 ~ /<title>Switch / && $0 !~ /Switch 2 /) print
|
||||||
| grep -E '^(2[1-9]|[3-9][0-9])\.' \
|
}')
|
||||||
| head -n 1)
|
|
||||||
|
|
||||||
if [ -z "$LATEST_VERSION" ]; then
|
DESCRIPTION=$(echo "$ITEM" | grep -oP '<description>\K[^<]+')
|
||||||
echo "INFO: Aucune nouvelle version majeure (>= 21.0.0) détectée."
|
|
||||||
echo "new_version=false" >> "$GITHUB_OUTPUT"
|
if [ -z "$DESCRIPTION" ]; then
|
||||||
|
echo "INFO: Aucun firmware Switch valide trouvé."
|
||||||
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
echo "Description détectée : $DESCRIPTION"
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION")
|
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" = "200" ]; then
|
# Extraire version
|
||||||
echo "new_version=false" >> "$GITHUB_OUTPUT"
|
VERSION=$(echo "$DESCRIPTION" | grep -oP '^Switch \K[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
else
|
|
||||||
echo "new_version=true" >> "$GITHUB_OUTPUT"
|
if [ -z "$VERSION" ]; then
|
||||||
echo "latest_v=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
|
echo "INFO: Impossible d'extraire la version."
|
||||||
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 💻 Execute download script
|
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||||
|
|
||||||
|
# 🔒 Bloque tout < 21
|
||||||
|
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érifier si la release existe déjà
|
||||||
|
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")
|
||||||
|
|
||||||
|
if [ "$HTTP_STATUS" == "200" ]; then
|
||||||
|
echo "INFO: La release $VERSION existe déjà."
|
||||||
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "INFO: Nouvelle version $VERSION détectée !"
|
||||||
|
echo "new_version=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "firmware_version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- 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: |
|
||||||
python3 firmware_downloader.py "${{ steps.version_check.outputs.latest_v }}" | tee firmware_output.txt
|
python3 firmware_downloader.py | tee firmware_output.txt
|
||||||
FIRMWARE_VERSION=$(grep 'Firmware_' firmware_output.txt | head -n1 | sed 's/.*Firmware_//')
|
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}')
|
||||||
|
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
tail -n 4 firmware_output.txt > changelog_body.txt
|
||||||
|
|
||||||
if [ -z "$FIRMWARE_VERSION" ]; then
|
- name: 🧹 Clean and zip firmware
|
||||||
FIRMWARE_VERSION="${{ steps.version_check.outputs.latest_v }}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "firmware_version=$FIRMWARE_VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
echo "## 🎮 Nintendo Switch Firmware $FIRMWARE_VERSION" > release_notes.md
|
|
||||||
echo "Téléchargé automatiquement." >> release_notes.md
|
|
||||||
echo "### Détails :" >> release_notes.md
|
|
||||||
echo '```text' >> release_notes.md
|
|
||||||
tail -n 15 firmware_output.txt >> release_notes.md
|
|
||||||
echo '```' >> release_notes.md
|
|
||||||
|
|
||||||
- name: 🧹 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 }}"
|
||||||
DIR_NAME=$(ls -d Firmware*${VERSION}* | head -n 1)
|
|
||||||
zip -rj "Firmware_$VERSION.zip" "$DIR_NAME/"
|
|
||||||
|
|
||||||
- name: 📦 Create Release on GitHub
|
# Supprimer fichiers temporaires .nca.*
|
||||||
|
find . -type f -name "*.nca.*" -delete
|
||||||
|
|
||||||
|
if [ -d "Firmware $VERSION" ]; then
|
||||||
|
rm -f "Firmware $VERSION.zip"
|
||||||
|
zip -rj "Firmware $VERSION.zip" "Firmware $VERSION/" -i "*.nca"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 📝 Prepare Release Body
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
core.setOutput('release_body', 'No changelog available.');
|
||||||
|
}
|
||||||
|
|
||||||
|
- 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_path: release_notes.md
|
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:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户