Skip to content

Commit ce0180d

Browse files
committed
fix:删除无效文件夹
1 parent 6f5059d commit ce0180d

File tree

7 files changed

+168
-143
lines changed

7 files changed

+168
-143
lines changed

.build/README.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 84 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ jobs:
105105
run: |
106106
fyne package --os android --app-id com.oneclickvirt.goecs --app-version "${{ needs.prepare.outputs.app_version }}" --release
107107
if [ -f *.apk ]; then
108-
mkdir -p .build
109-
mv *.apk .build/goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
108+
mv *.apk goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
110109
echo "ARM64 APK 构建成功"
111-
ls -lh .build/goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
110+
ls -lh goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
112111
else
113112
echo "ARM64 APK 构建失败"
114113
exit 1
@@ -122,9 +121,9 @@ jobs:
122121
run: |
123122
fyne package --os android/amd64 --app-id com.oneclickvirt.goecs --app-version "${{ needs.prepare.outputs.app_version }}" --release
124123
if [ -f *.apk ]; then
125-
mv *.apk .build/goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
124+
mv *.apk goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
126125
echo "x86_64 APK 构建成功"
127-
ls -lh .build/goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
126+
ls -lh goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
128127
else
129128
echo "x86_64 APK 构建失败"
130129
exit 1
@@ -139,34 +138,35 @@ jobs:
139138
140139
- name: Compress APK with UPX
141140
run: |
142-
cd .build
143-
for apk in *.apk; do
144-
echo "压缩前大小: $(du -h "$apk")"
145-
# 解压 APK
146-
unzip -q "$apk" -d "${apk%.apk}_extracted"
147-
148-
# 对 lib 目录下的 .so 文件使用 UPX 压缩
149-
find "${apk%.apk}_extracted/lib" -name "*.so" -type f | while read so_file; do
150-
echo "正在压缩: $so_file"
151-
upx --best --lzma "$so_file" || echo "警告: $so_file 压缩失败,继续处理"
152-
done
153-
154-
# 重新打包 APK
155-
cd "${apk%.apk}_extracted"
156-
zip -r -q "../${apk%.apk}_compressed.apk" .
157-
cd ..
158-
159-
# 替换原 APK
160-
mv "${apk%.apk}_compressed.apk" "$apk"
161-
rm -rf "${apk%.apk}_extracted"
162-
163-
echo "压缩后大小: $(du -h "$apk")"
141+
for apk in goecs-gui-android-*.apk; do
142+
if [ -f "$apk" ]; then
143+
echo "压缩前大小: $(du -h "$apk")"
144+
# 解压 APK
145+
unzip -q "$apk" -d "${apk%.apk}_extracted"
146+
147+
# 对 lib 目录下的 .so 文件使用 UPX 压缩
148+
find "${apk%.apk}_extracted/lib" -name "*.so" -type f | while read so_file; do
149+
echo "正在压缩: $so_file"
150+
upx --best --lzma "$so_file" || echo "警告: $so_file 压缩失败,继续处理"
151+
done
152+
153+
# 重新打包 APK
154+
cd "${apk%.apk}_extracted"
155+
zip -r -q "../${apk%.apk}_compressed.apk" .
156+
cd ..
157+
158+
# 替换原 APK
159+
mv "${apk%.apk}_compressed.apk" "$apk"
160+
rm -rf "${apk%.apk}_extracted"
161+
162+
echo "压缩后大小: $(du -h "$apk")"
163+
fi
164164
done
165165
166166
- name: List build artifacts
167167
run: |
168-
ls -lh .build/
169-
du -sh .build/*.apk
168+
ls -lh goecs-gui-android-*.apk
169+
du -sh goecs-gui-android-*.apk
170170
171171
- name: Get release
172172
id: get_release
@@ -186,8 +186,7 @@ jobs:
186186
- name: Upload to release
187187
shell: bash
188188
run: |
189-
cd .build
190-
for file in *; do
189+
for file in goecs-gui-android-*.apk; do
191190
if [ -f "$file" ]; then
192191
echo "Uploading $file to release ${{ steps.get_release.outputs.RELEASE_TAG }}"
193192
gh release upload "${{ steps.get_release.outputs.RELEASE_TAG }}" "$file" --clobber
@@ -200,14 +199,14 @@ jobs:
200199
uses: actions/upload-artifact@v4
201200
with:
202201
name: goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}
203-
path: .build/goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
202+
path: goecs-gui-android-arm64-${{ needs.prepare.outputs.version }}.apk
204203
retention-days: 90
205204

206205
- name: Upload x86_64 APK
207206
uses: actions/upload-artifact@v4
208207
with:
209208
name: goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}
210-
path: .build/goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
209+
path: goecs-gui-android-x86_64-${{ needs.prepare.outputs.version }}.apk
211210
retention-days: 90
212211

213212
build-desktop:
@@ -271,6 +270,18 @@ jobs:
271270
fi
272271
cat FyneApp.toml
273272
273+
- name: Install UPX
274+
shell: bash
275+
run: |
276+
if [ "${{ runner.os }}" == "macOS" ]; then
277+
brew install upx
278+
elif [ "${{ runner.os }}" == "Windows" ]; then
279+
curl -L https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-win64.zip -o upx.zip
280+
unzip upx.zip
281+
echo "$PWD/upx-4.2.1-win64" >> $GITHUB_PATH
282+
fi
283+
upx --version
284+
274285
- name: Build for ${{ matrix.name }}
275286
env:
276287
GOPRIVATE: github.com/oneclickvirt/security
@@ -286,11 +297,9 @@ jobs:
286297
fyne package -os darwin -name goecs --exe goecs-bin --app-version "${{ needs.prepare.outputs.app_version }}" --release
287298
288299
if [ -d goecs.app ]; then
289-
mkdir -p .build
290300
TARFILE="goecs-gui-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.tar.gz"
291301
echo "Creating tar file: $TARFILE"
292302
tar -czf "$TARFILE" goecs.app
293-
mv "$TARFILE" .build/
294303
echo "✓ macOS app 构建成功"
295304
else
296305
echo "✗ macOS app 构建失败"
@@ -303,8 +312,7 @@ jobs:
303312
304313
if [ "${{ matrix.platform }}" == "windows" ]; then
305314
if [ -f goecs.exe ]; then
306-
mkdir -p .build
307-
mv goecs.exe .build/goecs-gui-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.exe
315+
mv goecs.exe goecs-gui-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.exe
308316
echo "✓ Windows exe 构建成功"
309317
else
310318
echo "✗ Windows exe 构建失败"
@@ -313,11 +321,47 @@ jobs:
313321
fi
314322
fi
315323
324+
- name: Compress with UPX
325+
shell: bash
326+
run: |
327+
for file in goecs-gui-${{ matrix.name }}-*; do
328+
if [ -f "$file" ]; then
329+
echo "压缩前大小: $(du -h "$file")"
330+
331+
if [[ "$file" == *.exe ]]; then
332+
# Windows exe 直接压缩
333+
echo "正在压缩 Windows exe: $file"
334+
upx --best --lzma "$file" || echo "警告: $file 压缩失败"
335+
echo "压缩后大小: $(du -h "$file")"
336+
elif [[ "$file" == *.tar.gz ]]; then
337+
# macOS app 需要解压后压缩二进制
338+
echo "正在处理 macOS app: $file"
339+
tar -xzf "$file"
340+
341+
# 查找并压缩 macOS 可执行文件
342+
if [ -d goecs.app/Contents/MacOS ]; then
343+
for binary in goecs.app/Contents/MacOS/*; do
344+
if [ -f "$binary" ] && [ -x "$binary" ]; then
345+
echo "正在压缩 macOS 二进制: $binary"
346+
upx --best --lzma "$binary" || echo "警告: $binary 压缩失败"
347+
fi
348+
done
349+
fi
350+
351+
# 重新打包
352+
rm "$file"
353+
tar -czf "$file" goecs.app
354+
rm -rf goecs.app
355+
echo "压缩后大小: $(du -h "$file")"
356+
fi
357+
fi
358+
done
359+
316360
- name: List build artifacts
317361
shell: bash
318362
run: |
319-
ls -lh .build/
320-
du -sh .build/*
363+
ls -lh goecs-gui-${{ matrix.name }}-*
364+
du -sh goecs-gui-${{ matrix.name }}-*
321365
322366
- name: Get release
323367
id: get_release
@@ -337,8 +381,7 @@ jobs:
337381
- name: Upload to release
338382
shell: bash
339383
run: |
340-
cd .build
341-
for file in *; do
384+
for file in goecs-gui-${{ matrix.name }}-*; do
342385
if [ -f "$file" ]; then
343386
echo "Uploading $file to release ${{ steps.get_release.outputs.RELEASE_TAG }}"
344387
gh release upload "${{ steps.get_release.outputs.RELEASE_TAG }}" "$file" --clobber

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
*.apk
33
*.aab
44

5-
# Build directory (prevent large files from being committed)
6-
.build/
5+
# Build artifacts
6+
goecs-*
7+
!goecs-desktop
78

89
# Vendor
910
vendor/

0 commit comments

Comments
 (0)