Updated workflow
This commit is contained in:
50
.github/workflows/firmware-autodl.yml
vendored
50
.github/workflows/firmware-autodl.yml
vendored
@@ -31,33 +31,34 @@ jobs:
|
|||||||
cp hactool-linux hactool
|
cp hactool-linux hactool
|
||||||
chmod +x hactool
|
chmod +x hactool
|
||||||
|
|
||||||
- name: 🔍 Check firmware version (Switch 1 only)
|
- name: 🔍 Check firmware version (Switch 1 only, 21.0.0+)
|
||||||
id: version_check
|
id: version_check
|
||||||
run: |
|
run: |
|
||||||
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | \
|
LATEST_TITLE=$(curl -s 'https://yls8.mtheall.com/ninupdates/feed.php' | \
|
||||||
grep '<title>Switch ' | \
|
grep '<title>Switch ' | \
|
||||||
grep -v '<title>Switch 2 ' | \
|
grep -v '<title>Switch 2 ' | \
|
||||||
|
grep -E 'Switch ([2-9][1-9]|[3-9][0-9])\.' | \
|
||||||
head -n 1)
|
head -n 1)
|
||||||
|
|
||||||
if [ -z "$LATEST_TITLE" ]; then
|
|
||||||
echo "::error::Could not retrieve the firmware title for Switch 1 from the RSS feed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
|
LATEST_VERSION=$(echo "$LATEST_TITLE" | grep -oP 'Switch \K[0-9.]+')
|
||||||
|
|
||||||
if [ -z "$LATEST_VERSION" ]; then
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
echo "::error::Failed to parse LATEST_VERSION from title: $LATEST_TITLE"
|
echo "INFO: Aucune version récente (>= 21.x) trouvée."
|
||||||
exit 1
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAG_EXISTS=$(git ls-remote --tags origin $LATEST_VERSION)
|
echo "Version détectée : $LATEST_VERSION"
|
||||||
|
|
||||||
if [ ! -z "$TAG_EXISTS" ]; then
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
echo "INFO: Tag $LATEST_VERSION already exists on GitHub. Stopping workflow to avoid re-upload."
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION")
|
||||||
|
|
||||||
|
if [ "$HTTP_STATUS" == "200" ]; then
|
||||||
|
echo "INFO: La release $LATEST_VERSION existe déjà."
|
||||||
echo "new_version=false" >> $GITHUB_OUTPUT
|
echo "new_version=false" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "INFO: New version $LATEST_VERSION found! Preparing to download..."
|
echo "INFO: Nouvelle version $LATEST_VERSION détectée !"
|
||||||
echo "new_version=true" >> $GITHUB_OUTPUT
|
echo "new_version=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -67,13 +68,20 @@ jobs:
|
|||||||
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}')
|
FIRMWARE_VERSION=$(grep 'Folder: Firmware ' firmware_output.txt | awk '{print $NF}')
|
||||||
|
|
||||||
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT
|
echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
tail -n 4 firmware_output.txt > changelog_body.txt
|
tail -n 4 firmware_output.txt > changelog_body.txt
|
||||||
|
|
||||||
|
- name: 🧹 Clean .nca files
|
||||||
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
|
run: |
|
||||||
|
find . -type f -name "*.nca.*" -delete
|
||||||
|
VERSION="${{ steps.download.outputs.firmware_version }}"
|
||||||
|
if [ -d "Firmware $VERSION" ]; then
|
||||||
|
rm -f "Firmware $VERSION.zip"
|
||||||
|
zip -rj "Firmware $VERSION.zip" "Firmware $VERSION/" -i "*.nca"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: 📝 Prepare Release Body
|
- name: 📝 Prepare Release Body
|
||||||
id: prepare_body
|
id: prepare_body
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
@@ -81,16 +89,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
if (fs.existsSync('changelog_body.txt')) {
|
||||||
const changelogBody = fs.readFileSync('changelog_body.txt', 'utf8');
|
const changelogBody = fs.readFileSync('changelog_body.txt', 'utf8');
|
||||||
core.setOutput('release_body', changelogBody);
|
core.setOutput('release_body', changelogBody);
|
||||||
|
}
|
||||||
- name: 📦 Create firmware zip
|
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
|
||||||
run: |
|
|
||||||
VER="${{ steps.download.outputs.firmware_version }}"
|
|
||||||
DIR="Firmware $VER"
|
|
||||||
zip -r "$DIR.zip" "$DIR"
|
|
||||||
echo "Zip created: $DIR.zip"
|
|
||||||
|
|
||||||
- name: 📦 Create Tag and Release
|
- name: 📦 Create Tag and Release
|
||||||
if: steps.version_check.outputs.new_version == 'true'
|
if: steps.version_check.outputs.new_version == 'true'
|
||||||
@@ -107,8 +109,6 @@ jobs:
|
|||||||
|
|
||||||
${{ steps.prepare_body.outputs.release_body }}
|
${{ steps.prepare_body.outputs.release_body }}
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
files: |
|
files: |
|
||||||
Firmware ${{ steps.download.outputs.firmware_version }}.zip
|
Firmware ${{ steps.download.outputs.firmware_version }}.zip
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user