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 '
Switch ' | grep -v '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
echo "version=$LATEST_VERSION" >> $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="Firmware ${{ steps.version_check.outputs.version }}"
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: |
zip -r "Firmware ${{ steps.version_check.outputs.version }}.zip" \
"Firmware ${{ steps.version_check.outputs.version }}"
- name: ๐ Create GitHub Release
if: steps.version_check.outputs.new_version == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version_check.outputs.version }}
name: Firmware ${{ steps.version_check.outputs.version }}
body_path: release_body.txt
files: Firmware ${{ steps.version_check.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}