aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/build_windows.yml
blob: d3be53b29dc2ba04869a0e2b0d23a1beceace5eb (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build Windows

on:
  push:
    branches:
      - master
    paths-ignore:
      - '**.md'
    tags:
      - '*'
  pull_request:
    paths-ignore:
      - '**.md'

jobs:
  build-windows:
    runs-on: windows-latest
    # https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup devcmd
        uses: ilammy/msvc-dev-cmd@v1

      # https://learn.microsoft.com/en-us/vcpkg/users/binarycaching#gha
      - name: Set variables for vcpkg
        uses: actions/github-script@v7
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', (process.env.ACTIONS_CACHE_URL || ''));
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', (process.env.ACTIONS_RUNTIME_TOKEN || ''));

      - name: Install Qt
        uses: jurplel/install-qt-action@v4
        with:
          version: 6.10.0
          modules: qt5compat qtmultimedia
          cache: true

      - name: Install dependencies with vcpkg
        run: |
          # create our own triplet
          New-Item `
            -Force `
            -ItemType File `
            -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-release.cmake"
          Add-Content `
            -Path "${{ env.vcpkg_path }}/triplets_overlay/x64-windows-release.cmake" `
            -Value @("set(VCPKG_TARGET_ARCHITECTURE x64)",
              "set(VCPKG_LIBRARY_LINKAGE dynamic)",
              "set(VCPKG_CRT_LINKAGE dynamic)",
              "set(VCPKG_BUILD_TYPE release)")
          c:/vcpkg/vcpkg.exe install `
            --binarysource="clear;x-gha,readwrite" `
            --clean-after-build `
            --overlay-triplets="${{ env.vcpkg_path }}/triplets_overlay" `
            gettext[core,tools]:x64-windows-release `
            openssl:x64-windows-release `
            zlib:x64-windows-release

      - name: Patch Perl for MSVC support
        run: |
          # Strawberry perl doesn't support MSVC, but we force the support.
          cd '${{github.workspace}}'
          type dist\windows\patches\perl.txt >> c:\Strawberry\perl\lib\core\config.h

      # To debug add -DCMAKE_VERBOSE_MAKEFILE=1 `
      - name: Configure CMake
        run: |
          cd '${{github.workspace}}'
          mkdir build
          cd build
          cmake .. `
            -G "NMake Makefiles" `
            -DCMAKE_TOOLCHAIN_FILE="c:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
            -DVCPKG_TARGET_TRIPLET=x64-windows-release `
            -DCMAKE_BUILD_TYPE=Release `
            -DWANT_KDE=NO `
            -DWANT_OPENSSL=YES `
            -DWANT_PERL=YES `
            -DWANT_PHONON=NO `
            -DWANT_PYTHON=YES `
            -DWANT_QTWEBENGINE=NO

      - name: Build
        run: |
          cd '${{github.workspace}}\build'
          cmake --build .

      - name: Install
        run: |
          cd '${{github.workspace}}\build'
          cmake --install .

      - name: Deployt Qt
        run: |
          cd '${{github.workspace}}\build'
          windeployqt "--dir" "release/qt-plugins" "--libdir" "release/" "release/kvirc.exe" "release/modules/"; if (!$?) { exit 1 }

      - name: Deploy 3rd party dlls
        run: |
          cd '${{github.workspace}}\build'
          copy c:\vcpkg\installed\x64-windows-release\bin\z.dll release; if (!$?) { exit 1 }
          copy c:\vcpkg\installed\x64-windows-release\bin\libcrypto*.dll release; if (!$?) { exit 1 }
          copy c:\vcpkg\installed\x64-windows-release\bin\libssl*.dll release; if (!$?) { exit 1 }

      - name: Detect version
        shell: bash
        run: |
          cd '${{github.workspace}}'
          kvi_version=$(grep -i "^set(VERSION_RELEASE .*)$" CMakeLists.txt | egrep -o '[0-9\.]' | tr -d '\n')
          git_desc=$(git describe --always)
          echo "exe_name=KVIrc-$kvi_version-dev-$(date +%F)-git-$git_desc" >> "$GITHUB_ENV"

      - name: Install NSIS
        uses: repolevedavaj/install-nsis@v1.2.0
        with:
          nsis-version: '3.11'

      - name: Add StdUtils plugin to NSIS
        run: |
          (New-Object Net.WebClient).DownloadFile('https://github.com/lordmulder/stdutils/releases/download/1.14/StdUtils.2018-10-27.zip', 'c:\StdUtils.2018-10-27.zip')
          7z e -o"C:\Program Files (x86)\NSIS\Plugins\x86-unicode" c:\StdUtils.2018-10-27.zip Plugins\Unicode\*.dll
          7z e -o"C:\Program Files (x86)\NSIS\Include" c:\StdUtils.2018-10-27.zip Include\*.nsh

      - name: Create setup package
        run: |
          cd '${{github.workspace}}\build'
          makensis.exe KVIrc.nsi
          move KVIrc.exe ${{ env.exe_name }}.exe

      - name: Publish artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.exe_name }}.exe
          path: build/${{ env.exe_name }}.exe