This commit is contained in:
A13501350
2025-09-21 03:20:48 +08:00
parent df8e7e4400
commit 66b20eaa08

View File

@@ -9,157 +9,178 @@ on:
- v2/test-ci-windows - v2/test-ci-windows
jobs: jobs:
build: # build:
strategy: # strategy:
matrix: # matrix:
arch: [x86, x64] # arch: [x86, x64]
runs-on: windows-latest # runs-on: windows-latest
# For Caching # # For Caching
permissions: # permissions:
actions: read # actions: read
contents: read # contents: read
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v5 # uses: actions/checkout@v5
- name: Install Apache for x86 # - name: Install Apache for x86
if: matrix.arch == 'x86' # if: matrix.arch == 'x86'
shell: pwsh # shell: pwsh
run: | # run: |
$apachePath = "${{ github.workspace }}\apache-x86" # $apachePath = "${{ github.workspace }}\apache-x86"
New-Item -ItemType Directory -Path $apachePath -Force # New-Item -ItemType Directory -Path $apachePath -Force
choco install apache-httpd -y --force --forcex86 --no-progress -r --params="`"/installLocation:$apachePath /noService`"" # choco install apache-httpd -y --force --forcex86 --no-progress -r --params="`"/installLocation:$apachePath /noService`""
echo "APACHE_ROOT=$apachePath\Apache24" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append # echo "APACHE_ROOT=$apachePath\Apache24" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Set Apache path for x64 # - name: Set Apache path for x64
if: matrix.arch == 'x64' # if: matrix.arch == 'x64'
shell: pwsh # shell: pwsh
run: | # run: |
echo "APACHE_ROOT=C:\tools\Apache24" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append # echo "APACHE_ROOT=C:\tools\Apache24" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup MSYS2 # - name: Setup MSYS2
uses: msys2/setup-msys2@v2 # uses: msys2/setup-msys2@v2
with: # with:
msystem: ${{ matrix.arch == 'x86' && 'MINGW32' || 'UCRT64' }} # msystem: ${{ matrix.arch == 'x86' && 'MINGW32' || 'UCRT64' }}
update: true # update: true
install: > # install: >
git # git
make # make
autoconf # autoconf
automake # automake
libtool # libtool
${{ matrix.arch == 'x86' && 'mingw-w64-i686-gcc' || 'mingw-w64-ucrt-x86_64-gcc' }} # ${{ matrix.arch == 'x86' && 'mingw-w64-i686-gcc' || 'mingw-w64-ucrt-x86_64-gcc' }}
${{ matrix.arch == 'x86' && 'mingw-w64-i686-pkg-config' || 'mingw-w64-ucrt-x86_64-pkg-config' }} # ${{ matrix.arch == 'x86' && 'mingw-w64-i686-pkg-config' || 'mingw-w64-ucrt-x86_64-pkg-config' }}
- name: Clone and build ssdeep # - name: Clone and build ssdeep
shell: msys2 {0} # shell: msys2 {0}
run: | # run: |
MSYS2_WORKSPACE=$(cygpath -u '${{ github.workspace }}') # MSYS2_WORKSPACE=$(cygpath -u '${{ github.workspace }}')
echo "Converted workspace path: $MSYS2_WORKSPACE" # echo "Converted workspace path: $MSYS2_WORKSPACE"
git clone https://github.com/ssdeep-project/ssdeep.git --depth 1 # git clone https://github.com/ssdeep-project/ssdeep.git --depth 1
cd ssdeep # cd ssdeep
autoreconf -i # autoreconf -i
if [ "${{ matrix.arch }}" = "x86" ]; then # if [ "${{ matrix.arch }}" = "x86" ]; then
./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3" --build=i686-pc-mingw32 # ./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3" --build=i686-pc-mingw32
else # else
./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3" # ./configure --enable-shared --disable-static CFLAGS="-O3" CXXFLAGS="-O3"
fi # fi
make dll # make dll
mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin" # mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin"
mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include" # mkdir -p "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include"
cp -v fuzzy.dll "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin/" # cp -v fuzzy.dll "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/bin/"
cp -v fuzzy.h "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include/" # cp -v fuzzy.h "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/include/"
cp -v fuzzy.def "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/" # cp -v fuzzy.def "${MSYS2_WORKSPACE}/ssdeep-install-${{ matrix.arch }}/"
- name: Restore vcpkg cache # - name: Restore vcpkg cache
id: vcpkg-cache # id: vcpkg-cache
uses: TAServers/vcpkg-cache@v3 # uses: TAServers/vcpkg-cache@v3
with: # with:
token: ${{ secrets.GITHUB_TOKEN }} # token: ${{ secrets.GITHUB_TOKEN }}
prefix: vcpkg-iis-module-${{ matrix.arch }}/ # prefix: vcpkg-iis-module-${{ matrix.arch }}/
- name: Configure CMake for IIS Module # - name: Configure CMake for IIS Module
env: # env:
VCPKG_FEATURE_FLAGS: "binarycaching" # VCPKG_FEATURE_FLAGS: "binarycaching"
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite" # VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch }}-windows # VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch }}-windows
run: | # run: |
$archFlag = "${{ matrix.arch }}" # $archFlag = "${{ matrix.arch }}"
$cmakeArch = if ($archFlag -eq "x86") { "Win32" } else { "x64" } # $cmakeArch = if ($archFlag -eq "x86") { "Win32" } else { "x64" }
$installDir = if ($archFlag -eq "x86") { "x86" } else { "amd64" } # $installDir = if ($archFlag -eq "x86") { "x86" } else { "amd64" }
cmake ` # cmake `
-DAPACHE_ROOT="$env:APACHE_ROOT" ` # -DAPACHE_ROOT="$env:APACHE_ROOT" `
-DSSDEEP_ROOT="${{ github.workspace }}\ssdeep-install-${{ matrix.arch }}" ` # -DSSDEEP_ROOT="${{ github.workspace }}\ssdeep-install-${{ matrix.arch }}" `
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\iis\release\$installDir" ` # -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\iis\release\$installDir" `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" ` # -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" `
-A $cmakeArch ` # -A $cmakeArch `
-DWITH_SSDEEP=ON ` # -DWITH_SSDEEP=ON `
-DWITH_LUA=ON ` # -DWITH_LUA=ON `
-DWITH_YAJL=ON ` # -DWITH_YAJL=ON `
-S IIS -B "iis\build-${{ matrix.arch }}" # -S IIS -B "iis\build-${{ matrix.arch }}"
- name: Build IIS Module # - name: Build IIS Module
shell: pwsh # shell: pwsh
run: | # run: |
cmake --build "iis\build-${{ matrix.arch }}" --config Release # cmake --build "iis\build-${{ matrix.arch }}" --config Release
- name: Upload artifacts # - name: Upload artifacts
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: iis-module-${{ matrix.arch }} # name: iis-module-${{ matrix.arch }}
path: iis/build-${{ matrix.arch }}/Release/ # path: iis/build-${{ matrix.arch }}/Release/
package: # package:
needs: build # needs: build
# runs-on: windows-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v5
# - name: Download x64 artifacts
# uses: actions/download-artifact@v4
# with:
# name: iis-module-x64
# path: iis/release/amd64/
# - name: Download x86 artifacts
# uses: actions/download-artifact@v4
# with:
# name: iis-module-x86
# path: iis/release/x86/
# - name: Generate wxs files
# shell: pwsh
# run: |
# heat dir "iis\release\amd64" -cg ModSec64Components -dr inetsrv64 -gg -sreg -srd -var var.ModSecurityIISRelease64 -out "iis\ModSec64.wxs"
# heat dir "iis\release\x86" -cg ModSec32Components -dr inetsrv32 -gg -sreg -srd -var var.ModSecurityIISRelease32 -out "iis\ModSec32.wxs"
# - name: Compile wxs files
# shell: pwsh
# run: |
# candle.exe -ext WixUtilExtension -ext WixUIExtension "iis\installer.wxs" "iis\ModSec64.wxs" -arch x64 -dModSecurityIISRelease64="iis\release\amd64\" -out iis\
# candle.exe -ext WixUtilExtension -ext WixUIExtension "iis\ModSec32.wxs" -arch x86 -dModSecurityIISRelease32="iis\release\x86\" -out iis\
# - name: Link wixobj files into MSI
# shell: pwsh
# run: |
# light.exe -ext WixUtilExtension -ext WixUIExtension "iis\installer.wixobj" "iis\ModSec32.wixobj" "iis\ModSec64.wixobj" -out "iis\modsecurityiis.msi"
# - name: Upload artifacts
# uses: actions/upload-artifact@v4
# with:
# name: modsecurityiis-installers
# path: iis/modsecurityiis.msi
test:
needs: package
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout code - name: Enable IIS Feature
uses: actions/checkout@v5
- name: Download x64 artifacts
uses: actions/download-artifact@v4
with:
name: iis-module-x64
path: iis/release/amd64/
- name: Download x86 artifacts
uses: actions/download-artifact@v4
with:
name: iis-module-x86
path: iis/release/x86/
- name: Generate wxs files
shell: pwsh shell: pwsh
run: | run: |
heat dir "iis\release\amd64" -cg ModSec64Components -dr inetsrv64 -gg -sreg -srd -var var.ModSecurityIISRelease64 -out "iis\ModSec64.wxs" $iisStatus = Get-WindowsFeature -Name Web-Server
heat dir "iis\release\x86" -cg ModSec32Components -dr inetsrv32 -gg -sreg -srd -var var.ModSecurityIISRelease32 -out "iis\ModSec32.wxs" if ($iisStatus.Installed -eq $false) {
Write-Host "IIS is not installed. Installing now..."
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
} else {
Write-Host "IIS is already installed."
}
Install-WindowsFeature -name Web-Server -IncludeManagementTools
Install-WindowsFeature -name Web-Server, Web-ASP, Web-Mgmt-Tools, Web-WebSockets
- name: Compile wxs files # - name: Download MSI
shell: pwsh # uses: actions/download-artifact@v4
run: | # with:
candle.exe -ext WixUtilExtension -ext WixUIExtension "iis\installer.wxs" "iis\ModSec64.wxs" -arch x64 -dModSecurityIISRelease64="iis\release\amd64\" -out iis\ # name: modsecurityiis-installers
candle.exe -ext WixUtilExtension -ext WixUIExtension "iis\ModSec32.wxs" -arch x86 -dModSecurityIISRelease32="iis\release\x86\" -out iis\ # path: iis/
- name: Link wixobj files into MSI # - name: Install MSI
shell: pwsh # shell: pwsh
run: | # run: |
light.exe -ext WixUtilExtension -ext WixUIExtension "iis\installer.wixobj" "iis\ModSec32.wixobj" "iis\ModSec64.wixobj" -out "iis\modsecurityiis.msi"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: modsecurityiis-installers
path: iis/installer/modsecurityiis.msi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: modsecurityiis-installers
path: iis/installer/modsecurityiis.msi