-
-
Notifications
You must be signed in to change notification settings - Fork 7
163 lines (148 loc) · 5.18 KB
/
build-exe.yml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# This workflow builds and tests the Windows installer for YTMusic Deleter.
name: Build and Verify (Windows)
on:
push:
branches: # prevent push on tags since that's handled by another workflow
- '**'
paths-ignore:
- '**.md'
- '.flake8'
- '.gitignore'
- '.pre-commit-comfig.yaml'
- '**/build-deb.yml'
- '**/build-dmg.yml'
- '**/pytest.yml'
- '**/release.yml'
pull_request:
workflow_dispatch:
workflow_call:
schedule:
- cron: '0 10 * * *'
concurrency:
group: build-exe
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
build:
runs-on: windows-latest
outputs:
installer-version: ${{ steps.json-properties.outputs.version }}
cli-version: ${{ steps.run-cli.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pdm-project/setup-pdm@v4
- name: Download fbs
env:
FBS_URL_ID: ${{ secrets.FBS_URL_ID }}
run: |
curl -L https://drive.google.com/uc?id=$FBS_URL_ID --output fbs_pro-1.2.1.tar.gz
- name: Install dependencies
run: |
pdm install -dG gui --no-editable
- name: Run CLI from venv
id: run-cli
run: |
. .venv/Scripts/activate
ytmusic-deleter
echo "version=$(ytmusic-deleter --version)" >> $GITHUB_OUTPUT
- name: Run fbs app
run: |
# Store the version argument
version_str="${{ steps.run-cli.outputs.version }}"
# Makes app run headless
export QT_QPA_PLATFORM=offscreen
# Launch the fbs app and kill it after 10 seconds, saving the output.
# We don't want the timing out to fail the job. Normally using `timeout --preserve-status` would handle this but
# still getting exit code "241" which is an unknown code. Alternatively, running the entire step in a separate
# script file allows using just `timeout 10s pdm fbs run` but would rather not do that.
output=$(timeout 10s pdm fbs run || true)
# Check if the output contains the right CLI version
if grep -q "$version_str" <<< "$output"; then
echo "GUI is running the right CLI version: $version_str"
else
echo "$version_str" not found in output, which was the following:
echo $output
exit 1
fi
- name: Freeze prep
run: |
pdm freeze-prep
- uses: nuget/setup-nuget@v2
- name: Install C++ Redist
shell: pwsh
run: |
Install-Module -Name VcRedist -Force
New-Item -Path C:\Temp\VcRedist -ItemType Directory
$VcList = Get-VcList -Export All | Where-Object { $_.Release -in "2010","2012" -and $_.Architecture -eq "x64" }
Save-VcRedist -VcList $VcList -Path C:\Temp\VcRedist
Install-VcRedist -VcList $VcList -Silent
- name: Freeze exe
run: |
pdm fbs freeze
- name: Run frozen exe
run: |
# Store the version argument
version_str="${{ steps.run-cli.outputs.version }}"
# Makes app run headless
export QT_QPA_PLATFORM=offscreen
# Launch the fbs app and kill it after 10 seconds, saving the output.
output=$(timeout 10s ./gui/target/YTMusic_Deleter/YTMusic_Deleter.exe || true)
# Check if the output contains the right CLI version
if grep -q "$version_str" <<< "$output"; then
echo "GUI is running the right CLI version: $version_str"
else
echo "$version_str" not found in output, which was the following:
echo $output
exit 1
fi
- name: Create installer
run: |
pdm fbs installer
- name: Get base.json file
id: json-properties
uses: zoexx/[email protected]
with:
file_path: gui/src/build/settings/base.json
- name: Save .exe as artifact
id: upload_exe
uses: actions/upload-artifact@v4
with:
name: installer-exe
path: ./gui/target/YTMusic_Deleter-${{ steps.json-properties.outputs.version }}-Windows-Installer.exe
verify:
runs-on: windows-latest
needs: build
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: installer-exe
- name: Run installer
shell: cmd
run: |
.\YTMusic_Deleter-${{ needs.build.outputs.installer-version }}-Windows-Installer.exe /S
- name: Run application
uses: nick-fields/retry@v3
with:
shell: bash
command: |
# Makes app run headless
export QT_QPA_PLATFORM=offscreen
logfile="$APPDATA\YTMusic_Deleter\ytmusic-deleter-gui_$(date +%Y-%m-%d).log"
timeout 10s /c/Program\ Files\ \(x86\)/YTMusic_Deleter/YTMusic_Deleter.exe || true
version_str="${{ needs.build.outputs.cli-version }}"
if grep -q "$version_str" $logfile; then
echo "GUI is running the right CLI version: $version_str"
else
echo "The string "$version_str" was not found in $logfile, contents below:"
cat $logfile
exit 1
fi
max_attempts: 5
timeout_minutes: 10