From 3c121a1b9d2ef78e851c37639db8c0b70782c0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:50:54 +0800 Subject: [PATCH] 7zsfx --- .github/workflows/release.yml | 8 +++++++- LunaTranslator/pack.py | 33 ++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 182905d4..44fd337c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,10 @@ jobs: with: name: ${{ matrix.fname }} path: build/${{ matrix.fname }}.zip + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.fname }} sfx + path: build/${{ matrix.fname }}.exe - name: loadversion id: loadversion @@ -47,6 +51,8 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.loadversion.outputs.version }} - files: build/${{ matrix.fname }}.zip + files: | + build/${{ matrix.fname }}.zip + build/${{ matrix.fname }}.exe env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LunaTranslator/pack.py b/LunaTranslator/pack.py index 891c749f..9af91882 100644 --- a/LunaTranslator/pack.py +++ b/LunaTranslator/pack.py @@ -8,23 +8,22 @@ if x86: targetdir=r'..\build\LunaTranslator_x86' launch=r'..\plugins\builds\_x86' downlevel=r'C:\Windows\SysWOW64\downlevel' - target='LunaTranslator_x86.zip' + target='LunaTranslator_x86' baddll='DLL64' else: baddll='DLL32' - target='LunaTranslator.zip' + target='LunaTranslator' launch=r'..\plugins\builds\_x64' nuitkadist=r'..\build\x64\LunaTranslator_main.dist' targetdir=r'..\build\LunaTranslator' downlevel=r'C:\Windows\system32\downlevel' if isdebug: targetdir+=r'_debug' + target+='_debug' if x86: nuitkadist=r'..\build\x86_debug\LunaTranslator_main.dist' - target='LunaTranslator_x86_debug.zip' else: nuitkadist=r'..\build\x64_debug\LunaTranslator_main.dist' - target='LunaTranslator_debug.zip' targetdir_in=rf'{targetdir}\LunaTranslator' @@ -107,6 +106,26 @@ for f in collect: with open(f,'wb') as ff: ff.write(bs) -if os.path.exists(rf'{targetdir}\..\{target}'): - os.remove(rf'{targetdir}\..\{target}') -os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA -mx9 {targetdir}\..\{target} {targetdir}') \ No newline at end of file +if os.path.exists(rf'{targetdir}\..\{target}.zip'): + os.remove(rf'{targetdir}\..\{target}.zip') +if os.path.exists(rf'{targetdir}\..\{target}.7z'): + os.remove(rf'{targetdir}\..\{target}.7z') +os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA -mx9 {targetdir}\..\{target}.zip {targetdir}') +os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=LZMA2 -mx9 {targetdir}\..\{target}.7z {targetdir}') + +with open(r'C:\Program Files\7-Zip\7z.sfx','rb') as ff: + sfx=ff.read() + +config=''' +;!@Install@!UTF-8! + + +;!@InstallEnd@! +''' +with open(rf'{targetdir}\..\{target}.7z','rb') as ff: + data=ff.read() + +with open(rf'{targetdir}\..\{target}.exe','wb') as ff: + ff.write(sfx) + ff.write(config.encode('utf8')) + ff.write(data) \ No newline at end of file