0
0
镜像自地址 https://github.com/THZoria/NX_Firmware.git 已同步 2026-04-09 10:41:13 +00:00
文件
NX_Firmware/.github/workflows/firmware-autodl.yml
工作流配置文件无效。请检查您的配置文件:yaml: line 39: mapping values are not allowed in this context
Zoria 5dfb4b0301 Enhance firmware auto downloader workflow
Updated the firmware auto downloader workflow to improve release notes preparation and streamline version checking.
2026-02-22 00:22:38 +01:00

101 行
3.6 KiB
YAML

name: 🎮 Firmware Auto Downloader (21.0.0+)
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
download_and_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: ⬇️ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: ⚙️ Install required Python modules
run: |
pip install requests anynet beautifulsoup4 pycryptodome
- name: ⬇️ Setup hactool-linux
run: |
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
- name: 🔍 Check firmware version (Filter: 21.0.0+)
id: version_check
run: |
RSS_FEED=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php')
LATEST_VERSION=$(echo "$RSS_FEED" | \
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
echo "INFO: Aucune nouvelle version majeure (>= 21.0.0) détectée."
echo "new_version=false" >> $GITHUB_OUTPUT
exit 0
fi
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/$LATEST_VERSION")
if [ "$HTTP_STATUS" == "200" ]; then
echo "new_version=false" >> $GITHUB_OUTPUT
else
echo "new_version=true" >> $GITHUB_OUTPUT
echo "latest_v=$LATEST_VERSION" >> $GITHUB_OUTPUT
fi
shell: bash
- name: 💻 Execute download script
id: download
if: steps.version_check.outputs.new_version == 'true'
run: |
python3 firmware_downloader.py "${{ steps.version_check.outputs.latest_v }}" | tee firmware_output.txt
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
# Préparation propre du corps de la release
echo "## 🎮 Nintendo Switch Firmware $FIRMWARE_VERSION" > release_notes.md
echo "Téléchargé automatiquement depuis les serveurs officiels." >> 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'
run: |
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
if: steps.version_check.outputs.new_version == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.download.outputs.firmware_version }}
name: Firmware ${{ steps.download.outputs.firmware_version }}
body_path: release_notes.md
files: |
Firmware_${{ steps.download.outputs.firmware_version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}