From bdbc6b5925ae92728490d71cbfd747837b496dbd Mon Sep 17 00:00:00 2001 From: Markus Frei Date: Tue, 28 Jan 2025 16:32:17 +0100 Subject: [PATCH] chore(ci/cd): improve build --- .github/workflows/lf-windows-build.yml | 81 +++++++++++++++++++------- linuxfabrik-monitoring-plugins.wxs | 0 2 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 linuxfabrik-monitoring-plugins.wxs diff --git a/.github/workflows/lf-windows-build.yml b/.github/workflows/lf-windows-build.yml index 547ecca7d..faea68995 100644 --- a/.github/workflows/lf-windows-build.yml +++ b/.github/workflows/lf-windows-build.yml @@ -55,7 +55,8 @@ jobs: build-windows: runs-on: 'windows-latest' - needs: 'build-windows-get-list' + needs: + - 'build-windows-get-list' strategy: matrix: check: '${{ fromJson(needs.build-windows-get-list.outputs.monitoring_plugin_list_json) }}' @@ -66,27 +67,19 @@ jobs: with: egress-policy: 'audit' - - name: 'Add msbuild to PATH' - uses: 'microsoft/setup-msbuild@v2' - if: "runner.os == 'Windows'" - - - name: 'Install WiX' - run: 'dotnet tool install --global wix' - if: "runner.os == 'Windows'" - - - name: 'checkout the monitoring-plugins repo' + - name: 'Checkout the monitoring-plugins repo' uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # v4.2.2 with: # Relative path under $GITHUB_WORKSPACE to place the repository path: 'monitoring-plugins' - - name: 'checkout the lib repo' + - name: 'Checkout the lib repo' uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # v4.2.2 with: repository: 'Linuxfabrik/lib' path: 'lib' - - name: 'install python3.12' + - name: 'Install python3.12' uses: 'actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38' # v5.4.0 with: python-version: '3.12' @@ -122,7 +115,8 @@ jobs: zip-windows: # we need to use windows here too, to be able to restore the cache (see https://github.com/marketplace/actions/cache#cache-version) runs-on: 'windows-latest' - needs: 'build-windows' + needs: + - 'build-windows' steps: - name: 'Harden Runner' @@ -130,24 +124,69 @@ jobs: with: egress-policy: 'audit' - - name: 'download all artifacts' + - name: 'Download all artifacts' uses: 'actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16' # v4.1.8 with: path: 'C:\artifacts' - - name: 'prepare plugins for zipping' + - name: 'Prepare plugins for zipping' shell: 'bash' run: | cd /c/artifacts - mkdir /c/output + mkdir /c/output-zip for dir in */*/; do echo "dir: $dir" - echo cp -rv $dir* /c/output/ - cp -rv $dir* /c/output/ + echo cp -rv $dir* /c/output-zip/ + cp -rv $dir* /c/output-zip/ done - - name: 'Upload build output' + - name: 'Upload build output-zip' + uses: 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08' # v4.6.0 + with: + name: 'linuxfabrik-monitoring-plugins.zip' + path: 'C:\output-zip\' + + + msi-windows: + runs-on: 'windows-latest' + needs: + - 'zip-windows' + steps: + + - name: 'Add msbuild to PATH' + uses: 'microsoft/setup-msbuild@v2' + + - name: 'Install WiX toolset' + run: 'dotnet tool install --global wix' + + - name: 'Prepare plugins for packaging' + shell: 'bash' + run: | + cd /c/artifacts + mkdir /c/output-msi + for dir in */*/; do + echo "dir: $dir" + echo cp -rv $dir* /c/output-msi/ + cp -rv $dir* /c/output-msi/ + done + + # -dr INSTALLFOLDER: Specifies the directory reference for the installation folder. + # -cg LFMP: Groups all harvested components under the LFMP ComponentGroup. + # -gg: Automatically generates GUIDs for the components. + # -srd: Suppresses the root directory from being included as a directory structure. + - name: 'Harvest files with Heat' + run: | + heat.exe dir /c/output-msi -dr INSTALLFOLDER -cg LFMP -gg -srd -out linuxfabrik-monitoring-plugins.wxs + shell: cmd + + - name: 'Build MSI (compile .wxs into .wixobj, link .wixobj into an .msi)' + run: | + candle.exe ${{ github.workspace }}\monitoring-plugins\linuxfabrik-monitoring-plugins.wxs -out linuxfabrik-monitoring-plugins.wixobj + light.exe linuxfabrik-monitoring-plugins.wixobj -out C:\output-msi\linuxfabrik-monitoring-plugins.msi + working-directory: . + + - name: 'Upload build output-msi' uses: 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08' # v4.6.0 with: - name: 'monitoring-plugins-windows' - path: 'C:\output\' + name: 'linuxfabrik-monitoring-plugins.msi' + path: 'C:\output-msi\' diff --git a/linuxfabrik-monitoring-plugins.wxs b/linuxfabrik-monitoring-plugins.wxs new file mode 100644 index 000000000..e69de29bb