Build LinkDown #139
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build LinkDown | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 16 * * *' | |
| permissions: | |
| contents: write | |
| jobs: | |
| Prepare: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Git Environment | |
| run: | | |
| git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| git config --global user.name github-actions[bot] | |
| - name: Clean Up | |
| run: | | |
| cd LinkDown | |
| cp nativehost.bat ../nativehost.bat.bak | |
| cp nativehost.py ../nativehost.py.bak | |
| cp chrome.json ../chrome.json.bak | |
| cp firefox.json ../firefox.json.bak | |
| rm -rf ./* | |
| mv ../nativehost.bat.bak nativehost.bat | |
| mv ../nativehost.py.bak nativehost.py | |
| mv ../chrome.json.bak chrome.json | |
| mv ../firefox.json.bak firefox.json | |
| rm -rf ../nativehost.bat.bak | |
| rm -rf ../nativehost.py.bak | |
| rm -rf ../chrome.json.bak | |
| rm -rf ../firefox.json.bak | |
| - name: Download yt-dlp | |
| run: | | |
| cd LinkDown | |
| curl -L -o yt-dlp.exe https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe | |
| - name: Download BBDown | |
| run: | | |
| cd LinkDown | |
| - name: Download BBDown | |
| run: | | |
| cd LinkDown | |
| url=$(curl -s https://api.github.com/repos/nilaoda/BBDown/releases/latest \ | |
| | grep browser_download_url \ | |
| | grep win-x64.zip \ | |
| | cut -d '"' -f 4) | |
| curl -L -o bbdown.zip "$url" | |
| unzip bbdown.zip | |
| rm bbdown.zip | |
| - name: Download Python | |
| run: | | |
| cd LinkDown | |
| latest=$(curl -s https://www.python.org/ftp/python/ \ | |
| | grep -oP 'href="3\.\d+\.\d+/' \ | |
| | grep -oP '3\.\d+\.\d+' \ | |
| | sort -Vr \ | |
| | while read v; do | |
| url="https://www.python.org/ftp/python/$v/python-$v-embed-amd64.zip" | |
| if curl -sfI "$url" > /dev/null; then | |
| echo $v | |
| break | |
| fi | |
| done) | |
| echo "Valid Python version: $latest" | |
| curl -L -o python.zip \ | |
| https://www.python.org/ftp/python/$latest/python-$latest-embed-amd64.zip | |
| unzip -o python.zip | |
| rm python.zip | |
| - name: Setup 7-Zip | |
| uses: milliewalky/setup-7-zip@v2 | |
| - name: Download FFmpeg | |
| run: | | |
| cd LinkDown | |
| curl -L -o ffmpeg.7z https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z | |
| 7z x ffmpeg.7z | |
| folder=$(find . -maxdepth 1 -type d -name "ffmpeg-*essentials_build" | head -n 1) | |
| cp "$folder/bin/ffmpeg.exe" . | |
| cp "$folder/bin/ffprobe.exe" . | |
| rm -rf ffmpeg.7z "$folder" | |
| - name: Upload Prepared Folder | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prepared | |
| path: . | |
| - name: Commit Changes | |
| run: | | |
| git add LinkDown/* | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Auto update dependencies ($(date +'%Y.%m.%d'))" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi | |
| Build: | |
| needs: Prepare | |
| runs-on: windows-latest | |
| steps: | |
| - name: Download Prepared Folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: prepared | |
| - name: Compile Setup Wizard | |
| uses: Minionguyjpro/Inno-Setup-Action@v1.2.2 | |
| with: | |
| path: LinkDown_Wizard.iss | |
| options: /O+ | |
| - name: Upload Installer | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: setup | |
| path: Output\linkdown_setup*.exe | |
| Upload: | |
| needs: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Release Folder | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: setup | |
| path: Output | |
| - name: Setup Git Environment | |
| run: | | |
| git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| git config --global user.name github-actions[bot] | |
| - name: Generate Release Tag | |
| id: tag | |
| run: | | |
| echo "release_version=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT | |
| - name: Upload to Releases | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| name: LinkDown ${{ steps.tag.outputs.release_version }} | |
| tag_name: ${{ steps.tag.outputs.release_version }} | |
| files: Output/linkdown_setup.exe |