-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (79 loc) · 3.38 KB
/
check-spotify-version.yml
File metadata and controls
105 lines (79 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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