trigger-version-check #1701
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: check the new spotify web version | |
| on: | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [trigger-version-check] | |
| concurrency: | |
| group: version-check-singleton | |
| cancel-in-progress: false | |
| jobs: | |
| check-version: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download latest release | |
| shell: pwsh | |
| run: | | |
| $downloadUrl = "https://github.com/LoaderSpot/web-versions/releases/latest/download/web_search.exe" | |
| Write-Host "Downloading: $downloadUrl" | |
| & curl.exe -L -o web_search.exe --retry 5 --retry-delay 5 --fail --silent --show-error $downloadUrl | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "Failed to download latest release. Skipping version check gracefully." | |
| if (Test-Path "web_search.exe") { Remove-Item "web_search.exe" } | |
| exit 0 | |
| } | |
| Write-Host "Downloaded successfully" | |
| - name: Run version checker | |
| id: check | |
| shell: pwsh | |
| run: | | |
| if (-not (Test-Path ".\web_search.exe")) { | |
| Write-Host "web_search.exe not found. Skipping check." | |
| exit 0 | |
| } | |
| Write-Host "Running web_search.exe..." | |
| $output = & .\web_search.exe 2>&1 | |
| $output | Where-Object { $_ -notmatch '^\{' } | ForEach-Object { Write-Host $_ } | |
| $jsonLine = $output | Where-Object { $_ -match '^\{.*"success"' } | Select-Object -First 1 | |
| if ($jsonLine) { | |
| Write-Host "`nJSON Output:" | |
| Write-Host $jsonLine | |
| $json = $jsonLine | ConvertFrom-Json | |
| echo "SUCCESS=$($json.success)" >> $env:GITHUB_OUTPUT | |
| echo "IS_NEW=$($json.is_new)" >> $env:GITHUB_OUTPUT | |
| echo "KEY=$($json.key)" >> $env:GITHUB_OUTPUT | |
| if ($json.data.clientVersion) { | |
| echo "CLIENT_VERSION=$($json.data.clientVersion)" >> $env:GITHUB_OUTPUT | |
| } | |
| if ($json.message) { | |
| echo "MESSAGE=$($json.message)" >> $env:GITHUB_OUTPUT | |
| } | |
| if ($json.error) { | |
| echo "ERROR=$($json.error)" >> $env:GITHUB_OUTPUT | |
| } | |
| } else { | |
| Write-Error "No JSON output found" | |
| exit 1 | |
| } | |
| - name: Commit new version | |
| if: steps.check.outputs.SUCCESS == 'true' && steps.check.outputs.IS_NEW == 'true' | |
| shell: pwsh | |
| run: | | |
| if (Test-Path "web_search.exe") { Remove-Item "web_search.exe" -Force } | |
| git config --local core.autocrlf false | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add versions_web.json | |
| git commit -m "Added version ${{ steps.check.outputs.CLIENT_VERSION }}" | |
| git pull --rebase --autostash origin main | |
| git push origin main | |
| - name: Version status | |
| if: steps.check.outputs.SUCCESS == 'true' | |
| run: | | |
| echo "${{ steps.check.outputs.MESSAGE }}" | |
| - name: Error occurred | |
| if: steps.check.outputs.SUCCESS == 'false' | |
| run: | | |
| echo "Error: ${{ steps.check.outputs.ERROR }}" | |
| exit 1 |