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

84 行
2.4 KiB
YAML

name: 🎮 Firmware Auto Downloader
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 dependencies
run: pip install requests anynet beautifulsoup4
- name: 🔧 Setup hactool
run: |
cp hactool-linux hactool
chmod +x hactool
- name: 🔍 Check latest Switch 1 firmware
id: version_check
shell: bash
run: |
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | grep '<title>Switch ' | grep -v '<title>Switch 2 ' | head -n 1)
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
if git ls-remote --tags origin "$LATEST_VERSION" | grep -q "$LATEST_VERSION"; then
echo "new_version=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "new_version=true" >> $GITHUB_OUTPUT
- name: ⬇️ Download firmware
if: steps.version_check.outputs.new_version == 'true'
run: |
python3 firmware_downloader.py | tee firmware_output.txt
- name: 🧹 Remove .nca.1 files
if: steps.version_check.outputs.new_version == 'true'
run: |
FOLDER=$(ls -d Firmware\ *)
find "$FOLDER" -name "*.nca.1" -delete
- name: 📝 Prepare changelog
if: steps.version_check.outputs.new_version == 'true'
run: |
{
echo "### Notes"
echo "- Official Nintendo Switch firmware download"
echo ""
tail -n 4 firmware_output.txt
} > release_body.txt
- name: 📦 Create firmware zip
if: steps.version_check.outputs.new_version == 'true'
run: |
FOLDER=$(ls -d Firmware\ *)
zip -r "$FOLDER.zip" "$FOLDER"
- name: 🚀 Create GitHub Release
if: steps.version_check.outputs.new_version == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.run_id }}
name: Firmware Release
body_path: release_body.txt
files: Firmware\ *.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}