Skip to content

Commit

Permalink
Update CI to generate MSI installer for Windows using WiX. (netdata#1…
Browse files Browse the repository at this point in the history
…8914)

* Update CI to generate MSI installer for Windows using WiX.

* Fix missing option for WiX install.

* Copy icon file alongside WiX sources.

* Run WiX in the build directory instead of CWD.
  • Loading branch information
Ferroin authored Nov 1, 2024
1 parent 99b2a7a commit 6cb5e58
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ jobs:
trusted-signing-account-name: Netdata
certificate-profile-name: Netdata
files-folder: ${{ github.workspace }}\packaging\windows
files-folder-filter: exe
files-folder-filter: msi
file-digest: SHA256
timestamp-rfc3161: "http://timestamp.acs.microsoft.com"
timestamp-digest: SHA256
Expand All @@ -352,7 +352,7 @@ jobs:
uses: actions/upload-artifact@v4.4.2
with:
name: windows-x86_64-installer
path: packaging\windows\netdata*.exe
path: packaging\windows\netdata*.msi
retention-days: 30
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,5 @@ build/
src/go/plugin/go.d/bin/
src/go/plugin/go.d/vendor

# ignore nsis installer
packaging/utils/netdata-installer-x64.exe

# ignore files used with msi installer
packaging/utils/*.msi

packaging/windows/*.msi
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,8 @@ if(OS_WINDOWS)
set(NETDATA_RES_FILES "packaging/windows/resources/netdata.rc")
configure_file(packaging/windows/resources/netdata.manifest.in ${CMAKE_SOURCE_DIR}/packaging/windows/resources/netdata.manifest @ONLY)

configure_file(packaging/windows/netdata.wxs.in ${CMAKE_SOURCE_DIR}/packaging/windows/netdata.wxs @ONLY)
configure_file(packaging/windows/netdata.wxs.in netdata.wxs @ONLY)
configure_file(packaging/windows/NetdataWhite.ico NetdataWhite.ico COPYONLY)
endif()

add_executable(netdata
Expand Down
2 changes: 1 addition & 1 deletion packaging/windows/compile-on-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}"
# shellcheck source=./win-build-dir.sh
. "${REPO_ROOT}/packaging/windows/win-build-dir.sh"

set -exu -o pipefail
set -eu -o pipefail

if [ -d "${build}" ]; then
rm -rf "${build}"
Expand Down
8 changes: 8 additions & 0 deletions packaging/windows/get-win-build-path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

REPO_ROOT="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"

# shellcheck source=./win-build-dir.sh
. "${REPO_ROOT}/packaging/windows/win-build-dir.sh"

cygpath -wa "${build}"
21 changes: 21 additions & 0 deletions packaging/windows/install-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,24 @@ if ($LastExitcode -ne 0) {
exit 1
}
}

Write-Host "Installing WiX toolset"
dotnet tool install -g wix

if ($LastExitcode -ne 0) {
exit 1
}

Write-Host "Adding WiX extensions"

wix extension -g add WixToolset.Util.wixext

if ($LastExitcode -ne 0) {
exit 1
}

wix extension -g add WixToolset.UI.wixext

if ($LastExitcode -ne 0) {
exit 1
}
24 changes: 4 additions & 20 deletions packaging/windows/package-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@

repo_root="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"

if [ -n "${BUILD_DIR}" ]; then
build="${BUILD_DIR}"
elif [ -n "${OSTYPE}" ]; then
if [ -n "${MSYSTEM}" ]; then
build="${repo_root}/build-${OSTYPE}-${MSYSTEM}"
else
build="${repo_root}/build-${OSTYPE}"
fi
elif [ "$USER" = "vk" ]; then
build="${repo_root}/build"
else
build="${repo_root}/build"
fi
# shellcheck source=./win-build-dir.sh
. "${repo_root}/packaging/windows/win-build-dir.sh"

set -exu -o pipefail
set -eu -o pipefail

# Regenerate keys everytime there is an update
if [ -d /opt/netdata/etc/pki/ ]; then
Expand Down Expand Up @@ -48,13 +37,8 @@ if [ ! -f "/cloud.txt" ]; then
fi
${GITHUB_ACTIONS+echo "::endgroup::"}

${GITHUB_ACTIONS+echo "::group::Packaging"}
${GITHUB_ACTIONS+echo "::group::Copy Files"}
tar -xf /msys2-latest.tar.zst -C /opt/netdata/ || exit 1
cp -R /opt/netdata/msys64/* /opt/netdata/ || exit 1
rm -rf /opt/netdata/msys64/
NDVERSION=$"$(grep 'CMAKE_PROJECT_VERSION:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
NDMAJORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MAJOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
NDMINORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MINOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"

/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${repo_root}/packaging/windows/installer.nsi"
${GITHUB_ACTIONS+echo "::endgroup::"}
23 changes: 23 additions & 0 deletions packaging/windows/package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,26 @@ $env:CHERE_INVOKING = 'yes'
if ($LastExitcode -ne 0) {
exit 1
}

if ($null -eq $env:BUILD_DIR) {
$builddir = & $msysbash -l "$PSScriptRoot\get-win-build-path.sh"

if ($LastExitcode -ne 0) {
exit 1
}
} else {
$builddir = $env:BUILD_DIR
}

Push-Location "$builddir"

$wixarch = "x64"

wix build -arch $wixarch -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out "$PSScriptRoot\netdata-$wixarch.msi" netdata.wxs

if ($LastExitcode -ne 0) {
Pop-Location
exit 1
}

Pop-Location
6 changes: 1 addition & 5 deletions packaging/windows/win-build-dir.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash

if [ -n "${BUILD_DIR}" ]; then
if (echo "${BUILD_DIR}" | grep -q -E "^[A-Z]:\\\\"); then
build="$(echo "${BUILD_DIR}" | sed -e 's/\\/\//g' -e 's/^\([A-Z]\):\//\/\1\//' -)"
else
build="${BUILD_DIR}"
fi
build="$(cygpath -u "${BUILD_DIR}")"
elif [ -n "${OSTYPE}" ]; then
if [ -n "${MSYSTEM}" ]; then
build="${REPO_ROOT}/build-${OSTYPE}-${MSYSTEM}"
Expand Down

0 comments on commit 6cb5e58

Please sign in to comment.