fix(ci): check each available Spotify Windows architecture

This commit is contained in:
amd64fox committed 2026-12-05 08:03:57 +03:00
1 parent 6801c8359c
commit 18823547e4
1 file changed
+99 -82
+99 -82
View File
@@ -11,45 +11,85 @@ on:
type: string
jobs:
build:
prepare:
runs-on: windows-latest
outputs:
version: ${{ steps.select.outputs.version }}
installers: ${{ steps.select.outputs.installers }}
steps:
- name: Prepare checks
id: prepare
- name: Select Windows installers
id: select
shell: powershell
env:
SPOTIFY_VERSION: ${{ inputs.version }}
run: |
$spotifyVersion = ([string]$env:SPOTIFY_VERSION).Trim()
$requested = ([string]$env:SPOTIFY_VERSION).Trim()
if ($requested -and $requested -notmatch '^\d+\.\d+\.\d+(?:\.\d+)?$') {
throw "Invalid Spotify version: $requested"
}
$jsonUrl = 'https://raw.githubusercontent.com/LoaderSpot/table/refs/heads/main/table/versions.json'
$manifest = Invoke-RestMethod -Uri $jsonUrl
$versions = $manifest.PSObject.Properties
if (-not $requested) {
$entry = $versions | Select-Object -First 1
}
elseif ($requested -match '^\d+\.\d+\.\d+$') {
$entry = $versions | Where-Object { $_.Name.StartsWith("$requested.") } |
Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1
}
else {
$entry = $versions[$requested]
}
if (-not $entry) { throw "No matching Spotify version in $jsonUrl for '$requested'" }
if ([string]::IsNullOrWhiteSpace($spotifyVersion)) {
$jsonUrl = "https://raw.githubusercontent.com/LoaderSpot/table/refs/heads/main/table/versions.json"
$resp = Invoke-RestMethod -Uri $jsonUrl
$version = $entry.Value.fullversion
if ($version -notmatch '^(\d+\.\d+\.\d+\.\d+)\.g[0-9a-f]+$' -or $Matches[1] -ne $entry.Name) {
throw "Invalid Spotify fullversion for $($entry.Name)"
}
# Use fullversion for the installer name
$latestEntry = $resp.PSObject.Properties | Select-Object -First 1
if (-not $latestEntry) {
throw "No Spotify versions found in $jsonUrl"
$windows = $entry.Value.win
$installers = @(foreach ($arch in 'x86', 'x64', 'arm64') {
if ($arch -notin $windows.PSObject.Properties.Name) {
Write-Host "::notice::Skipping $arch for Spotify $version because no installer is listed"
continue
}
$asset = $windows.$arch
@{ arch = $arch; url = $asset.url; size = $asset.size }
})
"version=$version" | Out-File $env:GITHUB_OUTPUT -Encoding utf8 -Append
"installers=$(ConvertTo-Json -InputObject $installers -Compress)" | Out-File $env:GITHUB_OUTPUT -Encoding utf8 -Append
$spotifyVersion = [string]$latestEntry.Value.fullversion
if ([string]::IsNullOrWhiteSpace($spotifyVersion) -or $spotifyVersion -notmatch '^\d+\.\d+\.\d+\.\d+\.g[0-9a-f]+$') {
throw "Invalid Spotify fullversion for $($latestEntry.Name)"
}
}
elseif ($spotifyVersion -notmatch '^\d+\.\d+\.\d+(?:\.\d+)?$') {
throw "Invalid Spotify version: $spotifyVersion"
build:
name: Check SpotX (${{ matrix.arch }})
needs: prepare
if: needs.prepare.outputs.installers != '[]'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare.outputs.installers) }}
steps:
- name: Run SpotX
id: spotx
shell: powershell
env:
SPOTIFY_VERSION: ${{ needs.prepare.outputs.version }}
SPOTIFY_ARCH: ${{ matrix.arch }}
INSTALLER_URL: ${{ matrix.url }}
INSTALLER_SIZE: ${{ matrix.size }}
run: |
$arch = $env:SPOTIFY_ARCH
$version = $env:SPOTIFY_VERSION
if (-not $env:INSTALLER_URL -or [long]$env:INSTALLER_SIZE -le 0) {
throw "Invalid $arch installer metadata for Spotify $version"
}
Write-Host "Selected Spotify version: $spotifyVersion"
# Incoming parameters
$parameters = @{
Verbose = $true
no_pause = $true
new_theme = $true
version = $spotifyVersion
version = $version
confirm_spoti_recomended_over = $true
cache_limit = 1000
block_update_on = $true
@@ -60,67 +100,44 @@ jobs:
adsections_off = $true
lyrics_block = $true
}
$spotxUrl = "https://raw.githubusercontent.com/SpotX-Official/SpotX/refs/heads/main/run.ps1"
Invoke-WebRequest -UseBasicParsing -Uri $spotxUrl -OutFile "$env:RUNNER_TEMP\spotx.ps1"
$parameters | Export-Clixml -LiteralPath "$env:RUNNER_TEMP\spotx-parameters.xml"
- name: Run SpotX (x64)
shell: powershell
run: |
$parameters = Import-Clixml -LiteralPath "$env:RUNNER_TEMP\spotx-parameters.xml"
$spotxScript = [scriptblock]::Create((Get-Content -LiteralPath "$env:RUNNER_TEMP\spotx.ps1" -Raw -Encoding UTF8))
& $spotxScript @parameters
- name: Run SpotX (ARM64 files)
if: ${{ !cancelled() && steps.prepare.outcome == 'success' }}
shell: powershell
run: |
$parameters = Import-Clixml -LiteralPath "$env:RUNNER_TEMP\spotx-parameters.xml"
$checkVersion = $parameters.version
$installedSpotify = Join-Path $env:APPDATA 'Spotify\Spotify.exe'
if (Test-Path -LiteralPath $installedSpotify) {
$checkVersion = (Get-Item -LiteralPath $installedSpotify).VersionInfo.FileVersion
}
$jsonUrl = 'https://raw.githubusercontent.com/LoaderSpot/table/refs/heads/main/table/versions.json'
$manifest = Invoke-RestMethod -Uri $jsonUrl
$entry = $manifest.PSObject.Properties | Where-Object {
$_.Name -eq $checkVersion -or $_.Value.fullversion -eq $checkVersion -or
($checkVersion -match '^\d+\.\d+\.\d+$' -and $_.Name.StartsWith("$checkVersion."))
} | Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1
$installer = $entry.Value.win.arm64
if (-not $installer.url -or $installer.size -le 0) {
throw "No ARM64 installer found for Spotify $checkVersion"
}
if ($entry.Value.fullversion -notmatch '^\d+\.\d+\.\d+\.\d+\.g[0-9a-f]+$') {
throw "Invalid Spotify fullversion for $checkVersion"
}
$installerPath = Join-Path $env:RUNNER_TEMP 'SpotifySetup-arm64.exe'
Write-Host "ARM64 Spotify version: $($entry.Value.fullversion)"
Write-Host "Source: $($installer.url)"
for ($attempt = 1; $attempt -le 3; $attempt++) {
Write-Host "ARM64 installer download attempt $attempt/3"
curl.exe -q -L --fail-with-body --connect-timeout 15 --progress-bar -o $installerPath --url $installer.url
if ($LASTEXITCODE -eq 0) {
$downloadedSize = (Get-Item -LiteralPath $installerPath).Length
if ($downloadedSize -eq $installer.size) { break }
Write-Warning "ARM64 installer size mismatch: expected $($installer.size), got $downloadedSize"
if ($arch -eq 'arm64') {
$installerPath = Join-Path $env:RUNNER_TEMP 'SpotifySetup-arm64.exe'
Write-Host "Source: $env:INSTALLER_URL"
for ($attempt = 1; $attempt -le 3; $attempt++) {
Write-Host "ARM64 installer download attempt $attempt/3"
curl.exe -q -L --fail-with-body --connect-timeout 15 --progress-bar -o $installerPath --url $env:INSTALLER_URL
if ($LASTEXITCODE -eq 0) {
$downloadedSize = (Get-Item -LiteralPath $installerPath).Length
if ($downloadedSize -eq [long]$env:INSTALLER_SIZE) { break }
Write-Warning "ARM64 installer size mismatch: expected $env:INSTALLER_SIZE, got $downloadedSize"
}
if ($attempt -eq 3) { throw 'ARM64 installer download failed after 3 attempts' }
Start-Sleep -Seconds 5
}
if ($attempt -eq 3) { throw 'ARM64 installer download failed after 3 attempts' }
Start-Sleep -Seconds 5
$unpackerUrl = 'https://raw.githubusercontent.com/SpotX-Official/Spotify-EXE-Unpacker/refs/heads/main/spotify_exe_unpacker.py'
$unpackerPath = Join-Path $env:RUNNER_TEMP 'spotify_exe_unpacker.py'
Invoke-WebRequest -UseBasicParsing -Uri $unpackerUrl -OutFile $unpackerPath
$parameters.SpotifyPath = Join-Path $env:RUNNER_TEMP 'Spotify-arm64'
$parameters.defender_exclusions_off = $true
python $unpackerPath $installerPath --output $parameters.SpotifyPath
if ($LASTEXITCODE -ne 0) { throw 'ARM64 installer extraction failed' }
}
else {
# On x64 Windows the x86 cutoff selects the native installer
$parameters.last_x86_full = if ($arch -eq 'x86') { $version } else { '0.0.0.0' }
}
$unpackerUrl = 'https://raw.githubusercontent.com/SpotX-Official/Spotify-EXE-Unpacker/refs/heads/main/spotify_exe_unpacker.py'
$unpackerPath = Join-Path $env:RUNNER_TEMP 'spotify_exe_unpacker.py'
Invoke-WebRequest -UseBasicParsing -Uri $unpackerUrl -OutFile $unpackerPath
$parameters.SpotifyPath = Join-Path $env:RUNNER_TEMP 'Spotify-arm64'
$parameters.version = $entry.Value.fullversion
$parameters.defender_exclusions_off = $true
python $unpackerPath $installerPath --output $parameters.SpotifyPath
if ($LASTEXITCODE -ne 0) { throw 'ARM64 installer extraction failed' }
$spotxScript = [scriptblock]::Create((Get-Content -LiteralPath "$env:RUNNER_TEMP\spotx.ps1" -Raw -Encoding UTF8))
$spotxUrl = "https://raw.githubusercontent.com/$env:GITHUB_REPOSITORY/$env:GITHUB_SHA/run.ps1"
$spotxPath = Join-Path $env:RUNNER_TEMP 'spotx.ps1'
Invoke-WebRequest -UseBasicParsing -Uri $spotxUrl -OutFile $spotxPath
$spotxScript = [scriptblock]::Create((Get-Content -LiteralPath $spotxPath -Raw -Encoding UTF8))
& $spotxScript @parameters
'completed=true' | Out-File $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Report incomplete SpotX check
if: steps.spotx.outputs.completed != 'true'
shell: powershell
run: throw 'SpotX stopped before completing the check'