diff --git a/.github/workflows/build_nupkg.yml b/.github/workflows/build_and_test.yml similarity index 72% rename from .github/workflows/build_nupkg.yml rename to .github/workflows/build_and_test.yml index c42c4704..9f551969 100644 --- a/.github/workflows/build_nupkg.yml +++ b/.github/workflows/build_and_test.yml @@ -1,4 +1,4 @@ -name: Nuget Pack +name: Build and Test on: push: @@ -18,29 +18,23 @@ jobs: with: dotnet-version: 9.0.x - - name: Restore dependencies - run: dotnet restore - - - name: Build library - run: dotnet build - - name: Run tests run: dotnet test - - name: Pack - run: dotnet pack + - name: Run publish script + run: ./publish-nix.sh -d - - name: Upload build + - name: Upload package uses: actions/upload-artifact@v4 with: name: 'Nuget Package' - path: 'BinaryObjectScanner/bin/Release/*.nupkg' + path: '*.nupkg' - name: Upload to rolling uses: ncipollo/release-action@v1.14.0 with: allowUpdates: True - artifacts: 'BinaryObjectScanner/bin/Release/*.nupkg' + artifacts: "*.nupkg,*.zip" body: 'Last built commit: ${{ github.sha }}' name: 'Rolling Release' prerelease: True diff --git a/.github/workflows/build_programs.yml b/.github/workflows/build_programs.yml deleted file mode 100644 index 51be173e..00000000 --- a/.github/workflows/build_programs.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Build Programs - -on: - push: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - project: [ExtractionTool, ProtectionScan] - runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64] - framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0] - conf: [Debug] #[Release, Debug] - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 9.0.x - - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}} - - - name: Archive build - run: | - cd ${{ matrix.project }}/bin/Debug/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ - zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ./ - - - name: Upload build - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }} - path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip - - - name: Upload to rolling - uses: ncipollo/release-action@v1.14.0 - with: - allowUpdates: True - artifacts: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip - body: 'Last built commit: ${{ github.sha }}' - name: 'Rolling Release' - prerelease: True - replacesArtifacts: True - tag: "rolling" - updateOnlyUnreleased: True diff --git a/README.md b/README.md index 1dd25608..81790748 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Binary Object Scanner -[![Program Build](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_programs.yml/badge.svg)](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_programs.yml) -[![Nuget Pack](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_nupkg.yml/badge.svg)](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_nupkg.yml) +[![Build and Test](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/SabreTools/BinaryObjectScanner/actions/workflows/build_and_test.yml) C# protection, packer, and archive scanning library. This currently compiles as a library so it can be used in any C# application. Two reference applications called `ProtectionScan` and `ExtractionTool` are also included to demonstrate the abilities of the library. For an example of a program implementing the library, see [MPF](https://github.com/SabreTools/MPF). diff --git a/publish-nix.sh b/publish-nix.sh old mode 100644 new mode 100755 index 144fc357..726701fd --- a/publish-nix.sh +++ b/publish-nix.sh @@ -10,13 +10,17 @@ # Optional parameters USE_ALL=false +INCLUDE_DEBUG=false NO_BUILD=false NO_ARCHIVE=false -while getopts "uba" OPTION; do +while getopts "udba" OPTION; do case $OPTION in u) USE_ALL=true ;; + d) + INCLUDE_DEBUG=true + ;; b) NO_BUILD=true ;; @@ -39,6 +43,7 @@ COMMIT=$(git log --pretty=%H -1) # Output the selected options echo "Selected Options:" echo " Use all frameworks (-u) $USE_ALL" +echo " Include debug builds (-d) $INCLUDE_DEBUG" echo " No build (-b) $NO_BUILD" echo " No archive (-a) $NO_ARCHIVE" echo " " @@ -93,14 +98,14 @@ if [ $NO_BUILD = false ]; then # Only .NET 5 and above can publish to a single file if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]; then - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then dotnet publish ExtractionTool/ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true fi dotnet publish ExtractionTool/ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false else - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then dotnet publish ExtractionTool/ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT fi dotnet publish ExtractionTool/ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false @@ -132,14 +137,14 @@ if [ $NO_BUILD = false ]; then # Only .NET 5 and above can publish to a single file if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]; then - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then dotnet publish ProtectionScan/ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true fi dotnet publish ProtectionScan/ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false else - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then dotnet publish ProtectionScan/ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT fi dotnet publish ProtectionScan/ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false @@ -172,8 +177,8 @@ if [ $NO_ARCHIVE = false ]; then fi fi - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then cd $BUILD_FOLDER/ExtractionTool/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/ if [[ $(echo ${NON_DLL_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ]]; then zip -r $BUILD_FOLDER/ExtractionTool_${FRAMEWORK}_${RUNTIME}_debug.zip . -x 'CascLib.dll' -x 'mspack.dll' -x 'StormLib.dll' @@ -216,8 +221,8 @@ if [ $NO_ARCHIVE = false ]; then fi fi - # Only include Debug if building all - if [ $USE_ALL = true ]; then + # Only include Debug if set + if [ $INCLUDE_DEBUG = true ]; then cd $BUILD_FOLDER/ProtectionScan/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/ if [[ $(echo ${NON_DLL_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ]]; then zip -r $BUILD_FOLDER/ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip . -x 'CascLib.dll' -x 'mspack.dll' -x 'StormLib.dll' diff --git a/publish-win.ps1 b/publish-win.ps1 index 0078ca0b..48c65346 100644 --- a/publish-win.ps1 +++ b/publish-win.ps1 @@ -12,6 +12,10 @@ param( [Alias("UseAll")] [switch]$USE_ALL, + [Parameter(Mandatory = $false)] + [Alias("IncludeDebug")] + [switch]$INCLUDE_DEBUG, + [Parameter(Mandatory = $false)] [Alias("NoBuild")] [switch]$NO_BUILD, @@ -30,6 +34,7 @@ $COMMIT = git log --pretty=format:"%H" -1 # Output the selected options Write-Host "Selected Options:" Write-Host " Use all frameworks (-UseAll) $USE_ALL" +Write-Host " Include debug builds (-IncludeDebug) $INCLUDE_DEBUG" Write-Host " No build (-NoBuild) $NO_BUILD" Write-Host " No archive (-NoArchive) $NO_ARCHIVE" Write-Host " " @@ -80,15 +85,15 @@ if (!$NO_BUILD.IsPresent) { # Only .NET 5 and above can publish to a single file if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK) { - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { dotnet publish ExtractionTool\ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true } dotnet publish ExtractionTool\ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false } else { - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { dotnet publish ExtractionTool\ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT } dotnet publish ExtractionTool\ExtractionTool.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false @@ -116,15 +121,15 @@ if (!$NO_BUILD.IsPresent) { # Only .NET 5 and above can publish to a single file if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK) { - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { dotnet publish ProtectionScan\ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true } dotnet publish ProtectionScan\ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false } else { - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { dotnet publish ProtectionScan\ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT } dotnet publish ProtectionScan\ProtectionScan.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false @@ -153,8 +158,8 @@ if (!$NO_ARCHIVE.IsPresent) { continue } - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { Set-Location -Path $BUILD_FOLDER\ExtractionTool\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\ if ($NON_DLL_FRAMEWORKS -contains $FRAMEWORK -or $NON_DLL_RUNTIMES -contains $RUNTIME) { 7z a -tzip -x'!CascLib.dll' -x'!mspack.dll' -x'!StormLib.dll' $BUILD_FOLDER\ExtractionTool_${FRAMEWORK}_${RUNTIME}_debug.zip * @@ -192,8 +197,8 @@ if (!$NO_ARCHIVE.IsPresent) { continue } - # Only include Debug if building all - if ($USE_ALL.IsPresent) { + # Only include Debug if set + if ($INCLUDE_DEBUG.IsPresent) { Set-Location -Path $BUILD_FOLDER\ProtectionScan\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\ if ($NON_DLL_FRAMEWORKS -contains $FRAMEWORK -or $NON_DLL_RUNTIMES -contains $RUNTIME) { 7z a -tzip -x'!CascLib.dll' -x'!mspack.dll' -x'!StormLib.dll' $BUILD_FOLDER\ProtectionScan_${FRAMEWORK}_${RUNTIME}_debug.zip *