-
Notifications
You must be signed in to change notification settings - Fork 33
238 lines (198 loc) · 9.62 KB
/
build.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: build LDDC
on:
push:
branches: main
paths:
- "**.py"
- ".github/workflows/build.yml"
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [macos-13, ubuntu-latest, windows-latest]
arch: [x64]
include:
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: ${{ matrix.arch }}
- name: Get arch
id: arch
shell: bash
run: |
if [[ ${{ matrix.arch }} == 'x64' ]]; then
echo "arch=amd64" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.arch }} == 'arm64' ]]; then
echo "arch=arm64" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.arch }} == 'win32' ]]; then
echo "arch=x86" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install Pillow pyinstaller
# pip install imageio
- name: Install EGL/upx
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install libegl1 upx
- name: Install create-dmg/upx
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install create-dmg upx
- name: Install upx/7zip
if: ${{ matrix.os == 'windows-latest' }}
run: |
choco install upx 7zip -y
- name: Get Information
id: info
shell: bash
run: |
echo "copyright=Copyright (C) $(python build_helper.py --task get_year) 沉默の金" >> $GITHUB_OUTPUT
echo "version=$(python build_helper.py --task get_version)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
#- name: Build Executable
# uses: Nuitka/Nuitka-Action@main
# with:
# nuitka-version: main
# script-name: LDDC.py
# standalone: true
# onefile: false
# enable-plugins: pyside6
# disable-console: true
# product-name: "LDDC"
# file-version: ${{ steps.info.outputs.version }}
# product-version: ${{ steps.info.outputs.version }}
# copyright: ${{ steps.info.outputs.copyright }}
# windows-icon-from-ico: "res/img/icon/logo.png"
# mingw64: true
# macos-app-icon: "res/img/icon/logo.png"
# macos-app-version: ${{ steps.info.outputs.version }}
# macos-create-app-bundle: true
- name: Build Executable
shell: bash
run: |
if ${{ matrix.os == 'ubuntu-latest' }} || ${{ matrix.os == 'windows-latest' }}
then
icon_filename="logo.ico"
elif ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-13' }}
then
icon_filename="logo.icns"
fi
if [[ ${{ matrix.arch }} == 'x64' ]]; then
target_arch="--target-arch x86_64"
elif [[ ${{ matrix.arch }} == 'arm64' ]]; then
target_arch="--target-arch arm64"
fi
pyinstaller --onedir --contents-directory . --clean --windowed --name LDDC --specpath dist/spec --distpath dist/dist --workpath dist/build --icon $(pwd)/res/img/icon/$icon_filename $target_arch LDDC.py
- name: create dmg
if: ${{ matrix.os == 'macos-latest' }}
run: |
create-dmg \
--volname "LDDC" \
--volicon "res/img/icon/logo.icns" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "LDDC.app" 200 190 \
--app-drop-link 600 185 \
dist/LDDC.dmg \
dist/dist/LDDC.app
mkdir -p upload
mv dist/LDDC.dmg upload/LDDC-${{ steps.info.outputs.version }}-${{ steps.arch.outputs.arch }}.dmg
- name: create deb package
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd dist
mkdir -p deb/DEBIAN
mkdir -p deb/usr/lib
mkdir -p deb/usr/bin
mkdir -p deb/usr/share/applications
mkdir -p deb/usr/share/icons/
cp -r ../res/img/icon/logo.ico deb/usr/share/icons/LDDC.ico
cp -RT dist/LDDC deb/usr/lib/LDDC
chmod +x deb/usr/lib/LDDC/LDDC
ln -s ../lib/LDDC/LDDC deb/usr/bin/LDDC
echo "Package: LDDC" >> deb/DEBIAN/control
echo "Version: ${{ steps.info.outputs.version }}" >> deb/DEBIAN/control
echo "Architecture: ${{ steps.arch.outputs.arch }}" >> deb/DEBIAN/control
echo "Maintainer: chenmozhijin" >> deb/DEBIAN/control
echo "Depends: libxcb-cursor-dev"
echo "Description: lyrics tool" >> deb/DEBIAN/control
echo "[Desktop Entry]" >> deb/usr/share/applications/LDDC.desktop
echo "Name=LDDC" >> deb/usr/share/applications/LDDC.desktop
echo "Comment=lyrics tool" >> deb/usr/share/applications/LDDC.desktop
echo "Exec=/usr/lib/LDDC/LDDC" >> deb/usr/share/applications/LDDC.desktop
echo "Icon=/usr/share/icons/LDDC.ico" >> deb/usr/share/applications/LDDC.desktop
echo "Terminal=false" >> deb/usr/share/applications/LDDC.desktop
echo "Type=Application" >> deb/usr/share/applications/LDDC.desktop
echo "X-Ubuntu-Touch=true" >> deb/usr/share/applications/LDDC.desktop
echo "Categories=Application" >> deb/usr/share/applications/LDDC.desktop
chmod +x deb/usr/share/applications/LDDC.desktop
sudo dpkg -b deb LDDC_${{ steps.info.outputs.version }}_${{ steps.arch.outputs.arch }}.deb
sudo apt install ./LDDC_${{ steps.info.outputs.version }}_${{ steps.arch.outputs.arch }}.deb
cd ..
mkdir upload
mv dist/LDDC_${{ steps.info.outputs.version }}_${{ steps.arch.outputs.arch }}.deb upload/LDDC_${{ steps.info.outputs.version }}_${{ steps.arch.outputs.arch }}.deb
- name: prepare create exe
if: ${{ matrix.os == 'windows-latest' }}
run: |
New-Item -ItemType Directory -Force -Path dist/exe/main/
New-Item -ItemType Directory -Force -Path dist/exe/main/other/
Copy-Item -Path dist/dist/LDDC/LDDC.exe -Destination dist/exe/main/LDDC.exe -Force
Copy-Item -Path dist/dist/LDDC/ -Destination dist/exe/other/ -Recurse -Force
Remove-Item -Path dist/exe/other/LDDC.exe -Force
- name: Generate evb
if: ${{ matrix.os == 'windows-latest' }}
uses: chenmozhijin/generate-evb@master
with:
inputExe: "dist/exe/main/LDDC.exe"
outputExe: "dist/exe/output/LDDC/LDDC.exe"
path2Pack: "dist/exe/other/"
evbFilePath: "dist/exe/LDDC.evb"
deleteExtractedOnExit: false
compressFiles: false
- name: create exe
if: ${{ matrix.os == 'windows-latest' }}
run: |
New-Item -Path "dist\exe\chen" -ItemType Directory -Force
New-Item -Path "dist\exe\tools" -ItemType Directory -Force
cd dist/exe/chen
$latest_release = Invoke-RestMethod -Uri "https://api.github.com/repos/dscharrer/innoextract/releases/latest"
$download_url = ($latest_release.assets | Where-Object { $_.browser_download_url -like "*windows.zip" }).browser_download_url
Invoke-WebRequest -Uri $download_url -OutFile "innoextract_windows.zip"
Expand-Archive -Path "innoextract_windows.zip" -DestinationPath "../tools" -Force
$enigmavb_url = "http://enigmaprotector.com/assets/files/enigmavb.exe"
Invoke-WebRequest -Uri $enigmavb_url -OutFile "../tools/enigmavb.exe"
cd ../tools
.\innoextract.exe enigmavb.exe
cd ../../..
dist/exe/tools/app/enigmavbconsole.exe dist/exe/LDDC.evb
- name: Upload dist
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }} - ${{ matrix.arch }} Build
path: |
dist/
- name: Compress exe
if: ${{ matrix.os == 'windows-latest' }}
run: |
New-Item -Path upload -ItemType Directory
cd dist/exe/output/
7z a -tzip -mx=9 ../../../upload/LDDC-${{ steps.info.outputs.version }}-windows-${{ steps.arch.outputs.arch }}.zip LDDC
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }} - ${{ matrix.arch }} artifacts
path: |
upload/