Skip to content

Commit

Permalink
feat: added shell definition in windows packages workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcr99 committed Feb 13, 2025
1 parent 072c908 commit 2151dfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/packages-build-windows-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,25 @@ jobs:
gh_token: ${{ secrets.CI_WAZUH_AGENT_PACKAGES_CLASSIC }}

- name: Set PKG_NAME
shell: bash
run: |
$VERSION = (Invoke-RestMethod -Uri "https://raw.githubusercontent.com/wazuh/wazuh-agent/${{ inputs.source_reference }}/src/VERSION") -match "([0-9]+\.[0-9]+\.[0-9]+)" ? $matches[1] : ""
$COMMIT_HASH = (Invoke-RestMethod -Uri "https://api.github.com/repos/wazuh/wazuh-agent/branches/${{ inputs.source_reference }}" | Select-String -Pattern '"sha"' | Select-Object -First 1) -match '"sha":\s*"(\w{7})"' ? $matches[1] : ""
if ("${{ inputs.is_stage }}" -eq "true") {
$PKG_NAME = "wazuh-agent-$VERSION-${{ inputs.revision }}"
} else {
$PKG_NAME = "wazuh-agent_${VERSION}-${{ inputs.revision }}_windows_${COMMIT_HASH}"
}
$BINARIES_NAME = "windows-build-${VERSION}-${{ inputs.revision }}_${COMMIT_HASH}"
echo "BINARIES_NAME=$BINARIES_NAME" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "PKG_NAME=$PKG_NAME" | Out-File -FilePath $env:GITHUB_ENV -Append
VERSION=$(curl -s "https://raw.githubusercontent.com/wazuh/wazuh-agent/${{ inputs.source_reference }}/src/VERSION" | sed 's/.*\([0-9]\.[0-9]*\.[0-9]*\).*/\1/')
COMMIT_HASH="$(curl -s "https://api.github.com/repos/wazuh/wazuh-agent/branches/${{ inputs.source_reference }}" | grep '"sha"' | head -1 | sed 's/.*: "\(.*\)",/\1/' | cut -c1-7)"
if [ "${{ inputs.is_stage }}" == "true" ]; then
echo "PKG_NAME=wazuh-agent-${VERSION}-${{ inputs.revision }}" >> $GITHUB_ENV
else
echo "PKG_NAME=wazuh-agent_${VERSION}-${{ inputs.revision }}_windows_${COMMIT_HASH}" >> $GITHUB_ENV
fi
echo "BINARIES_NAME=windows-build-${VERSION}-${{ inputs.revision }}_${COMMIT_HASH}" >> $GITHUB_ENV
- name: Build binaries for Windows package
- name: Build MSI for Windows package
run: |
./packages/windows/generate_compiled_windows_agent.ps1 -MSI_NAME ${{ env.PKG_NAME }} -CMAKE_CONFIG RelWithDebInfo -BUILD_TESTS 1
./packages/windows/generate_wazuh_msi.ps1 -MSI_NAME ${{ env.PKG_NAME }} -CMAKE_CONFIG RelWithDebInfo -DEBUG yes &> /tmp/generate_msi.log
- name: Build MSI for Windows package
shell: bash
run: |
./wazuh-agent/packages/windows/generate_wazuh_msi.ps1 -MSI_NAME ${{ env.PKG_NAME }} -CMAKE_CONFIG RelWithDebInfo -DEBUG yes" &> /tmp/generate_msi.log
cat /tmp/generate_msi.log
if [ "$(grep -c 'SignTool Error' /tmp/generate_msi.log)" -ne "0" ] ; then
echo "The generation and sign could not be completed."
Expand Down
2 changes: 1 addition & 1 deletion packages/windows/generate_compiled_windows_agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ mkdir build -Force
$Env:CUSTOM_PACKAGE_NAME = $MSI_NAME
$Env:CUSTOM_CMAKE_CONFIG = $CMAKE_CONFIG
cmake src -B build -DBUILD_TESTS=$BUILD_TESTS -G "Visual Studio 17 2022" -A x64
cmake --build build --config $CMAKE_CONFIG
cmake --build build --config $CMAKE_CONFIG --parallel (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
cd $originalDir

0 comments on commit 2151dfa

Please sign in to comment.