Skip to content

Commit

Permalink
Add Github Action for generating release binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmilk committed Feb 18, 2023
1 parent 8b011d2 commit f095403
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 75 deletions.
132 changes: 57 additions & 75 deletions .github/workflows/build-win.yml
Expand Up @@ -6,13 +6,12 @@
# 15.0 https://learn.microsoft.com/en-us/visualstudio/releases/2017/vs2017-compatibility-vs
# 16.0 https://learn.microsoft.com/en-us/visualstudio/releases/2019/compatibility
# 17.0 https://learn.microsoft.com/en-us/visualstudio/releases/2022/compatibility
# -> take 16.0 for now /TR
# -> we take 16.0 for now /TR
########################################################################################

name: Build Windows binaries
on: [push, pull_request]

# runs-on: windows-latest -> VS 17.0

jobs:
build:
Expand All @@ -39,167 +38,150 @@ jobs:

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3
with:
vs-version: 16.11

- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}

- name: Compile ${{ matrix.arch }}
- name: Compiling ${{ matrix.arch }}
shell: cmd
run: |
set APPVEYOR_BUILD_FOLDER=%cd%
set CLOUD=TRUE
set VC=17.0
set WDIR=%cd%
set PLATFORM=${{matrix.platform}}
set SUBSYS=${{matrix.subsys}}
set DEBUG=${{ matrix.debug }}
set ROOT=%cd%\CPP\7zip
set OUTDIR=%WDIR%\build\bin-%PLATFORM%
set LFLAGS=/SUBSYSTEM:WINDOWS,%SUBSYS%
echo "********"
echo "APPVEYOR_BUILD_FOLDER: %APPVEYOR_BUILD_FOLDER%"
echo "Platform: %PLATFORM%"
echo "SUBSYS: %SUBSYS%"
echo "Build: %DEBUG%"
echo "GithubAction: %CLOUD%"
cd cpp
@echo off
echo "Working Dir: %WDIR%"
echo "Platform: %PLATFORM%"
echo "SUBSYS: %SUBSYS%"
set ROOT=%cd%\7zip
set OUTDIR=%APPVEYOR_BUILD_FOLDER%\build\bin-%VC%-%PLATFORM%
set ERRFILE=%APPVEYOR_BUILD_FOLDER%\build\bin-%VC%-%PLATFORM%.log
set LFLAGS=/SUBSYSTEM:WINDOWS,%SUBSYS%
@echo off
set > %APPVEYOR_BUILD_FOLDER%\build\env-%VC%-%PLATFORM%.txt
set > %WDIR%\build\env-%PLATFORM%.txt
mkdir %OUTDIR%
cd %ROOT%\Bundles\Format7zExtract
nmake %OPTS%
IF %errorlevel% NEQ 0 echo "Error @ 7zxa.dll" >> %ERRFILE%
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zxa.dll %OUTDIR%\7zxa.dll
cd %ROOT%\Bundles\Format7z
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7za.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7za.dll %OUTDIR%\7za.dll
cd %ROOT%\Bundles\Format7zF
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7z.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7z.dll %OUTDIR%\7z.dll
cd %ROOT%\UI\FileManager
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7zFM.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zFM.exe %OUTDIR%\7zFM.exe
cd %ROOT%\UI\GUI
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7zG.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zG.exe %OUTDIR%\7zG.exe
cd %ROOT%\UI\Explorer
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7-zip.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7-zip.dll %OUTDIR%\7-zip.dll
cd %ROOT%\Bundles\SFXWin
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7z.sfx" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7z.sfx %OUTDIR%\7z.sfx
cd %ROOT%\Bundles\Codec_brotli
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ brotli.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\brotli.dll %OUTDIR%\brotli.dll
cd %ROOT%\Bundles\Codec_lizard
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ lizard.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\lizard.dll %OUTDIR%\lizard.dll
cd %ROOT%\Bundles\Codec_lz4
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ lz4.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\lz4.dll %OUTDIR%\lz4.dll
cd %ROOT%\Bundles\Codec_lz5
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ lz5.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\lz5.dll %OUTDIR%\lz5.dll
cd %ROOT%\Bundles\Codec_zstd
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ zstd.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\zstd.dll %OUTDIR%\zstd.dll
cd %ROOT%\Bundles\Codec_flzma2
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ flzma2.dll" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\flzma2.dll %OUTDIR%\flzma2.dll
cd %ROOT%\..\..\C\Util\7zipInstall
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ Install.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zipInstall.exe %OUTDIR%\Install.exe
cd %ROOT%\..\..\C\Util\7zipUninstall
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ Uninstall.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zipUninstall.exe %OUTDIR%\Uninstall.exe
set LFLAGS=/SUBSYSTEM:CONSOLE,%SUBSYS%
cd %ROOT%\UI\Console
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7z.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7z.exe %OUTDIR%\7z.exe
cd %ROOT%\Bundles\SFXCon
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7zCon.sfx" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7zCon.sfx %OUTDIR%\7zCon.sfx
cd %ROOT%\Bundles\Alone
nmake %OPTS%
IF %errorlevel% NEQ 0 (
echo "Error @ 7za.exe" >> %ERRFILE%
exit -1 )
IF %errorlevel% NEQ 0 EXIT 1
copy %PLATFORM%\7za.exe %OUTDIR%\7za.exe
REM Will be by the do-release action
copy %WDIR%\.github\workflows\do-release.cmd %WDIR%\build\do-release.cmd
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
# A file, directory or wildcard pattern that describes what to upload
path: ${{ github.workspace }}/build/**/*
path: ${{ github.workspace }}\build\**\*

do-release:
runs-on: windows-2019
needs: build
steps:
- uses: actions/download-artifact@v3

- name: Generate binaries for release
shell: cmd
run: |
cd artifact
do-release.cmd
- uses: geekyeggo/delete-artifact@v2
with:
name: artifact

- uses: actions/upload-artifact@v3
with:
name: 7-Zip ZS Release binaries
path: |
artifact\*.exe
artifact\*.7z
91 changes: 91 additions & 0 deletions .github/workflows/do-release.cmd
@@ -0,0 +1,91 @@
@echo off
REM Build some release of 7-Zip ZS

SET COPYCMD=/Y /B
SET COPTS=-m0=lzma -mx9 -ms=on -mf=bcj2
SET URL=https://www.7-zip.org/a/7z2201.exe
SET VERSION=22.01
SET SZIP="C:\Program Files\7-Zip\7z.exe"
SET LURL=https://raw.githubusercontent.com/mcmilk/7-Zip-zstd/master/CPP/7zip/Bundles

SET WD=%cd%
SET SKEL=%WD%\skel

REM Download our skeleton files
mkdir %SKEL%
cd %SKEL%
curl %URL% --output 7-Zip.exe
%SZIP% x 7-Zip.exe
mkdir %WD%\totalcmd
goto start

:doit
echo Doing ARCH=%ARCH% in SOURCE=%BIN%

REM 7-Zip Files
cd %SKEL%
del *.exe *.dll *.sfx
FOR %%f IN (7z.dll 7z.exe 7z.sfx 7za.dll 7za.exe 7zCon.sfx 7zFM.exe 7zG.exe 7-zip.dll 7zxa.dll Uninstall.exe) DO (
copy %BIN%\%%f %%f
)
IF DEFINED ZIP32 copy %ZIP32% 7-zip32.dll
%SZIP% a ..\%ARCH%.7z %COPTS%
cd %WD%
copy %BIN%\Install.exe + %ARCH%.7z 7z%VERSION%-zstd-%ARCH%.exe
del %ARCH%.7z

REM Codec Files
mkdir codecs-%ARCH%
FOR %%f IN (brotli flzma2 lizard lz4 lz5 zstd) DO (
copy %BIN%\%%f.dll codecs-%ARCH%\%%f.dll
)
cd codecs-%ARCH%
curl %LURL%/Codecs/LICENSE --output LICENSE
curl %LURL%/Codecs/README.md --output README.md
%SZIP% a ..\Codecs-%ARCH%.7z %COPTS%
cd %WD% && rd /S /Q Codecs-%ARCH%

REM Total Commander DLL
cd %WD%\totalcmd
copy %BIN%\7zxa.dll %TCDLL%
curl %LURL%/TotalCMD/LICENSE --output LICENSE
curl %LURL%/TotalCMD/README.md --output README.md
goto done_%ARCH%

REM Currently we build 4 architectures
:start
SET ARCH=x32
SET ZIP32=
SET BIN=%WD%\bin-x86
SET TCDLL=tc7z.dll
goto doit
:done_x32

SET ARCH=x64
SET ZIP32=%WD%\bin-x86\7-zip.dll
SET BIN=%WD%\bin-x64
SET TCDLL=tc7z64.dll
goto doit
:done_x64

SET ARCH=arm
SET ZIP32=
SET BIN=%WD%\bin-arm
SET TCDLL=tc7zarm.dll
goto doit
:done_arm

SET ARCH=arm64
SET ZIP32=%WD%\bin-arm\7-zip.dll
SET BIN=%WD%\bin-arm64
SET TCDLL=tc7zarm64.dll
goto doit
:done_arm64

cd %WD%\totalcmd
%SZIP% a ..\TotalCmd.7z %COPTS%

REM cleanup
cd %WD%
rd /S /Q %SKEL%
rd /S /Q %WD%\totalcmd
27 changes: 27 additions & 0 deletions CPP/7zip/Bundles/Codecs/LICENSE
@@ -0,0 +1,27 @@
7-Zip source code
~~~~~~~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Codecs Copyright (C) 2016 - 2023 Tino Reichardt.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

--
Tino Reichardt
27 changes: 27 additions & 0 deletions CPP/7zip/Bundles/Codecs/README.md
@@ -0,0 +1,27 @@

This archive contains two precompiled DLL's for 7-Zip v17.00 or higher.

## Installation

1. download the codec archiv from https://mcmilk.de/projects/7-Zip-zstd/
2. create a new directory named "Codecs"
3. put in there the files of the Codecs-ARCH.7z archiv to your Installation
- normally, the x32 should go to: "C:\Program Files (x86)\7-Zip\Codecs"
- x64: version should go in here: "C:\Program Files\7-Zip\Codecs"

## Usage

- when compressing binaries (*.exe, *.dll), you have to explicitly disable
the bcj2 filter via `-m0=bcj`
- so the usage should look like this:

```
7z a archiv.7z -m0=bcj -m1=zstd -mx1 ...Fast mode, with BCJ preprocessor on executables
7z a archiv.7z -m0=bcj -m1=zstd -mx.. ...
7z a archiv.7z -m0=bcj -m1=zstd -mx21 ...2nd Slowest Mode, with BCJ preprocessor on executables
7z a archiv.7z -m0=bcj -m1=zstd -mx22 ...Ultra Mode, with BCJ preprocessor on executables
```

## License and redistribution

- the same as the original 7-Zip, which means GNU LGPL

0 comments on commit f095403

Please sign in to comment.