-
-
Notifications
You must be signed in to change notification settings - Fork 7
189 lines (167 loc) · 5.66 KB
/
build-dmg.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# This workflow builds and tests the macOS installer for YTMusic Deleter.
name: Build and Verify (macOS)
on:
push:
branches: # prevent push on tags since that's handled by another workflow
- '**'
paths-ignore:
- '**.md'
- '.flake8'
- '.gitignore'
- '.pre-commit-comfig.yaml'
- '**/build-exe.yml'
- '**/build-deb.yml'
- '**/pytest.yml'
- '**/release.yml'
pull_request:
workflow_dispatch:
workflow_call:
schedule:
- cron: '0 10 * * *'
concurrency:
group: build-dmg
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
build:
strategy:
matrix:
os: [macos-13, macos-14]
runs-on: ${{ matrix.os }}
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
# adds `timeout` command
brew install coreutils
- name: Run CLI from venv
id: run-cli
run: |
. .venv/bin/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
- 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.app/Contents/MacOS/YTMusic_Deleter || 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
uses: nick-fields/retry@v3
with:
command: pdm fbs installer
max_attempts: 10
timeout_minutes: 20
- name: Get base.json file
id: json-properties
uses: zoexx/[email protected]
with:
file_path: gui/src/build/settings/base.json
- name: Rename installer per version
id: rename-installer
run: |
if [[ "${{ matrix.os }}" == "macos-13" ]]; then
ARCH=x86_64
else
ARCH=arm
fi
mv ./gui/target/mac-installer-to-be-renamed.dmg \
./gui/target/YTMusic_Deleter-${{ steps.json-properties.outputs.version }}-MacOS-Installer_$ARCH.dmg
echo "ARCH=$ARCH" >> $GITHUB_ENV
- name: Save .dmg as artifact
id: upload_dmg
uses: actions/upload-artifact@v4
with:
name: installer-dmg-${{ matrix.os }}
path: ./gui/target/YTMusic_Deleter-${{ steps.json-properties.outputs.version }}-MacOS-Installer_${{ env.ARCH }}.dmg
env:
ARCH: ${{ env.ARCH }}
verify:
strategy:
matrix:
os: [macos-13, macos-14]
runs-on: ${{ matrix.os }}
needs: build
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: installer-dmg-${{ matrix.os }}
- name: Attach app image
run: |
# Have to redefine arch
if [[ "${{ matrix.os }}" == "macos-13" ]]; then
ARCH=x86_64
else
ARCH=arm
fi
hdiutil attach ./YTMusic_Deleter-${{ needs.build.outputs.installer-version }}-MacOS-Installer_$ARCH.dmg
- name: Install dependencies
run: |
# adds `timeout` command
brew install coreutils
- name: Run application
run: |
# Makes app run headless
export QT_QPA_PLATFORM=offscreen
logfile="$HOME/YTMusic_Deleter/ytmusic-deleter-gui*.log"
timeout 10s /Volumes/YTMusic_Deleter/YTMusic_Deleter.app/Contents/MacOS/YTMusic_Deleter || 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