Skip to content

Commit 044ae2e

Browse files
committed
ci(workflow): 添加多平台构建和发布工作流
1 parent 9db3a1b commit 044ae2e

File tree

5 files changed

+525
-0
lines changed

5 files changed

+525
-0
lines changed

.github/workflows/build.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-windows:
12+
strategy:
13+
matrix:
14+
architecture: [ x86_64, arm64 ]
15+
runs-on: windows-2022
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python 3.13
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.13'
26+
27+
- name: Install dependencies
28+
run: |
29+
pip install --timeout=300 -r requirements.txt
30+
31+
- name: Build with Nuitka
32+
run: |
33+
python -c "from app.common.config import VERSION; f = open('version.txt', 'w'); f.write(VERSION); f.close(); f = open('Ghost-Downloader-3.iss', 'r+'); _ = f.read().replace('APPLICATION_VERSION', VERSION); f.seek(0); f.write(_); f.truncate(); f.close();"
34+
$VERSION = gc version.txt
35+
Write-Host "VERSION=$VERSION"
36+
echo "VERSION=$VERSION" >> $env:GITHUB_ENV
37+
del version.txt
38+
python deploy.py
39+
mv dist/Ghost-Downloader-3.dist dist/Ghost-Downloader-3-Unsigned.dist
40+
41+
- name: upload-unsigned-artifact
42+
id: upload-unsigned-artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Unsigned
46+
path: dist/Ghost-Downloader-3-Unsigned.dist
47+
48+
- name: Sign
49+
uses: signpath/github-action-submit-signing-request@v1.1
50+
with:
51+
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
52+
organization-id: '${{ secrets.SIGNPATH_ORGANIZATION_ID }}'
53+
project-slug: 'Ghost-Downloader-3'
54+
signing-policy-slug: 'release-signing'
55+
github-artifact-id: '${{ steps.upload-unsigned-artifact.outputs.artifact-id }}'
56+
wait-for-completion: true
57+
output-artifact-directory: 'dist/Ghost-Downloader-3.dist'
58+
59+
- name: Download Inno Setup Translation Files
60+
run: |
61+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "C:\Program Files (x86)\Inno Setup 6\Languages\ChineseSimplified.isl"
62+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseTraditional.isl" -OutFile "C:\Program Files (x86)\Inno Setup 6\Languages\ChineseTraditional.isl"
63+
64+
- name: Build Installer
65+
uses: Minionguyjpro/Inno-Setup-Action@v1.2.5
66+
with:
67+
path: Ghost-Downloader-3.iss
68+
69+
- name: Create zip file
70+
shell: pwsh
71+
run: |
72+
$distPath = "dist/Ghost-Downloader-3.dist"
73+
$zipFile = "Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}.zip"
74+
75+
# Create a zip file containing the contents of Ghost-Downloader.dist, without the folder itself
76+
Write-Output "Zipping contents of $distPath..."
77+
7z a -tzip -mx=9 -m0=LZMA Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}.zip dist/Ghost-Downloader-3.dist/*
78+
Write-Output "Zip created at $zipFile"
79+
80+
mv dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-Setup.exe dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Setup.exe
81+
82+
- name: Upload to release
83+
uses: softprops/action-gh-release@v2
84+
if: startsWith(github.ref, 'refs/tags/')
85+
with:
86+
files: |
87+
Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}.zip
88+
dist/Ghost-Downloader-v${{ env.VERSION }}-Windows-${{ matrix.architecture }}-Setup.exe
89+
90+
build-macos-14-arm:
91+
strategy:
92+
matrix:
93+
architecture: [ arm64 ]
94+
runs-on: macos-14
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v3
98+
with:
99+
fetch-depth: 0
100+
101+
- name: Set up Python 3.13
102+
uses: actions/setup-python@v4
103+
with:
104+
python-version: '3.13'
105+
106+
- name: Install dependencies
107+
run: |
108+
pip install --timeout=300 -r requirements.txt
109+
110+
- name: Build with Nuitka
111+
run: |
112+
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt
113+
version=$(sed -n '4p' version.txt)
114+
echo "VERSION=${version}" >> "$GITHUB_ENV"
115+
rm -rf version.txt
116+
python3 deploy.py
117+
chmod +x "dist/Ghost-Downloader-3.app/Contents/MacOS/Ghost-Downloader-3"
118+
rm -rf "dist/Ghost-Downloader-3.build"
119+
rm -rf "dist/Ghost-Downloader-3.dist"
120+
mv "dist/Ghost-Downloader-3.app" "dist/Ghost Downloader.app"
121+
mv "resources/修复软件损坏" "dist/修复软件损坏"
122+
123+
- name: Create DMG
124+
run: |
125+
ln -s /Applications dist/Applications
126+
127+
attempt=0
128+
max_attempts=10
129+
while [ $attempt -lt $max_attempts ]; do
130+
hdiutil create -srcfolder "dist/" -volname "Ghost-Downloader" -fs HFS+ \
131+
-fsargs "-c c=64,a=16,e=16" -format UDZO -size 400m \
132+
"Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg" && break
133+
134+
attempt=$((attempt + 1))
135+
echo "Attempt $attempt failed, retrying..."
136+
sleep 1 # 等待 1 秒后重试
137+
done
138+
139+
if [ $attempt -eq $max_attempts ]; then
140+
echo "Failed to create DMG after $max_attempts attempts"
141+
fi
142+
143+
- name: Upload to release
144+
uses: softprops/action-gh-release@v2
145+
if: startsWith(github.ref, 'refs/tags/')
146+
with:
147+
files: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg
148+
149+
build-macos-13-x86_64:
150+
strategy:
151+
matrix:
152+
architecture: [ x86_64 ]
153+
runs-on: macos-13
154+
steps:
155+
- name: Checkout
156+
uses: actions/checkout@v3
157+
with:
158+
fetch-depth: 0
159+
160+
- name: Remove problematic brew libs
161+
run: |
162+
brew remove --force --ignore-dependencies openssl@3
163+
brew cleanup openssl@3
164+
165+
- name: Set up Python 3.13
166+
uses: actions/setup-python@v4
167+
with:
168+
python-version: '3.13'
169+
170+
- name: Install dependencies
171+
run: |
172+
pip install --timeout=300 -r requirements.txt
173+
174+
- name: Build with Nuitka
175+
run: |
176+
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt
177+
version=$(sed -n '4p' version.txt)
178+
echo "VERSION=${version}" >> "$GITHUB_ENV"
179+
rm -rf version.txt
180+
python3 deploy.py
181+
chmod +x "dist/Ghost-Downloader-3.app/Contents/MacOS/Ghost-Downloader-3"
182+
rm -rf "dist/Ghost-Downloader-3.build"
183+
rm -rf "dist/Ghost-Downloader-3.dist"
184+
mv "dist/Ghost-Downloader-3.app" "dist/Ghost Downloader.app"
185+
mv "resources/修复软件损坏" "dist/修复软件损坏"
186+
187+
- name: Reinstall openssl libs
188+
run: |
189+
brew install openssl@3
190+
191+
- name: Create DMG
192+
run: |
193+
ln -s /Applications dist/Applications
194+
sleep 1
195+
hdiutil create -srcfolder "dist/" -volname "Ghost-Downloader-3" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDZO -size 400m "Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg"
196+
197+
- name: Upload to release
198+
uses: softprops/action-gh-release@v2
199+
if: startsWith(github.ref, 'refs/tags/')
200+
with:
201+
files: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg
202+
203+
build-ubuntu:
204+
strategy:
205+
matrix:
206+
architecture: [ x86_64, arm64 ]
207+
runs-on: ubuntu-22.04
208+
steps:
209+
- name: Checkout
210+
uses: actions/checkout@v3
211+
with:
212+
fetch-depth: 0
213+
214+
- name: Set up Python 3.13
215+
uses: actions/setup-python@v4
216+
with:
217+
python-version: '3.13'
218+
219+
- name: Install dependencies
220+
run: |
221+
sudo apt-get update
222+
sudo apt-get install -y libegl1-mesa
223+
pip install --timeout=300 -r requirements.txt
224+
225+
- name: Build with Nuitka
226+
run: |
227+
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt
228+
version=$(sed -n '4p' version.txt)
229+
echo "VERSION=${version}" >> "$GITHUB_ENV"
230+
rm -rf version.txt
231+
python deploy.py
232+
chmod +x "dist/Ghost-Downloader-3.dist/Ghost-Downloader-3.bin"
233+
234+
- name: Tar the contents of Ghost-Downloader
235+
shell: pwsh
236+
run: |
237+
$distPath = "dist/Ghost-Downloader-3.dist"
238+
$tarFile = "Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}.tar.xz"
239+
240+
# Create a tar.xz archive containing the contents of Ghost-Downloader.dist, without the folder itself
241+
Write-Output "Creating tar.xz archive of $distPath..."
242+
tar -cJf $tarFile -C $distPath .
243+
Write-Output "Archive created at $tarFile"
244+
245+
- name: Upload to release
246+
uses: softprops/action-gh-release@v2
247+
if: startsWith(github.ref, 'refs/tags/')
248+
with:
249+
files: Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}.tar.xz

.github/workflows/build_Linux.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build Linux
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-ubuntu:
8+
strategy:
9+
matrix:
10+
architecture: [ x86_64, arm64 ]
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python 3.13
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.13'
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y libegl1-mesa
27+
pip install --timeout=300 -r requirements.txt
28+
29+
- name: Build with Nuitka
30+
run: |
31+
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt
32+
version=$(sed -n '4p' version.txt)
33+
echo "VERSION=${version}" >> "$GITHUB_ENV"
34+
rm -rf version.txt
35+
python deploy.py
36+
37+
- name: Upload artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: Ghost-Downloader-v${{ env.VERSION }}-Linux-${{ matrix.architecture }}
41+
path: dist/Ghost-Downloader-3.dist

0 commit comments

Comments
 (0)