镜像自地址
https://github.com/THZoria/NX_Firmware.git
已同步 2026-04-09 10:41:13 +00:00
Refactor firmware autodl workflow for clarity and efficiency
Updated the workflow to install Python dependencies separately and improved the logic for checking firmware versions and creating releases.
这个提交包含在:
95
.github/workflows/firmware-autodl.yml
vendored
95
.github/workflows/firmware-autodl.yml
vendored
@@ -17,67 +17,92 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: 🐍 Setup Python
|
- name: 🐍 Setup Python and dependencies
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: ⚙️ Install dependencies
|
- name: ⚙️ Install required Python modules
|
||||||
run: pip install requests anynet beautifulsoup4
|
run: |
|
||||||
|
pip install requests anynet beautifulsoup4
|
||||||
|
|
||||||
- name: 🔧 Setup hactool
|
- name: ⬇️ Setup hactool-linux
|
||||||
run: |
|
run: |
|
||||||
cp hactool-linux hactool
|
cp hactool-linux hactool
|
||||||
chmod +x hactool
|
chmod +x hactool
|
||||||
|
|
||||||
- name: 🔍 Check latest Switch 1 firmware
|
- name: 🔍 Check firmware version (Switch 1 only)
|
||||||
id: version_check
|
id: version_check
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | grep '<title>Switch ' | grep -v '<title>Switch 2 ' | head -n 1)
|
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | \
|
||||||
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
|
grep '<title>Switch ' | \
|
||||||
|
grep -v '<title>Switch 2 ' | \
|
||||||
|
head -n 1)
|
||||||
|
|
||||||
if git ls-remote --tags origin "$LATEST_VERSION" | grep -q "$LATEST_VERSION"; then
|
if [ -z "$LATEST_TITLE" ]; then
|
||||||
echo "new_version=false" >> $GITHUB_OUTPUT
|
exit 1
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "new_version=true" >> $GITHUB_OUTPUT
|
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
|
||||||
|
|
||||||
- name: ⬇️ Download firmware
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAG_EXISTS=$(git ls-remote --tags origin $LATEST_VERSION)
|
||||||
|
|
||||||
|
if [ ! -z "$TAG_EXISTS" ]; then
|
||||||
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "new_version=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: 💻 Execute download script and capture changelog
|
||||||
|
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
|
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
|
||||||
|
tail -n 4 firmware_output.txt > changelog_body.txt
|
||||||
|
|
||||||
- name: 🧹 Remove .nca.1 files
|
- name: 🧹 Clean .nca files
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
run: |
|
run: |
|
||||||
FOLDER=$(ls -d Firmware\ *)
|
find . -type f -name "*.nca.*" -delete
|
||||||
find "$FOLDER" -name "*.nca.1" -delete
|
VERSION="${{ steps.download.outputs.firmware_version }}"
|
||||||
|
if [ -f "Firmware $VERSION.zip" ]; then
|
||||||
|
rm "Firmware $VERSION.zip"
|
||||||
|
zip -r "Firmware $VERSION.zip" "Firmware $VERSION" -i "*.nca"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: 📝 Prepare changelog
|
- name: 📝 Prepare Release Body
|
||||||
|
id: prepare_body
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
{
|
with:
|
||||||
echo "### Notes"
|
script: |
|
||||||
echo "- Official Nintendo Switch firmware download"
|
const fs = require('fs');
|
||||||
echo ""
|
const changelogBody = fs.readFileSync('changelog_body.txt', 'utf8');
|
||||||
tail -n 4 firmware_output.txt
|
core.setOutput('release_body', changelogBody);
|
||||||
} > release_body.txt
|
|
||||||
|
|
||||||
- name: 📦 Create firmware zip
|
- name: 📦 Create Tag and Release
|
||||||
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'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.run_id }}
|
tag_name: ${{ steps.download.outputs.firmware_version }}
|
||||||
name: Firmware Release
|
name: Firmware ${{ steps.download.outputs.firmware_version }}
|
||||||
body_path: release_body.txt
|
body: |
|
||||||
files: Firmware\ *.zip
|
Automatic download of the official Nintendo Switch firmware version **${{ steps.download.outputs.firmware_version }}**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Downloaded file details:**
|
||||||
|
|
||||||
|
${{ steps.prepare_body.outputs.release_body }}
|
||||||
|
|
||||||
|
files: |
|
||||||
|
Firmware ${{ steps.download.outputs.firmware_version }}.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户