aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/win-x64-build.yml
blob: 87440fb7547e89d0ca6b7a6ab492b4b29b2d26cc (plain)
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
name: Windows x64

on:
  push:
  pull_request:

jobs:
  build:
    runs-on: windows-latest
    env:
      CMAKE_BUILD_TYPE: RelWithDebInfo
      MYSQL_ROOT_DIR: C:/Program Files/MySQL/MySQL Server 8.0
      OPENSSL_ROOT_DIR: C:/libs/openssl
    steps:
    - uses: actions/checkout@v4

    - name: Set reusable strings
      id: strings
      shell: bash
      run: |
        echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

    - name: Get current OpenSSL version
      id: openssl-info
      run: |
        $VersionsUrl = "https://api.github.com/repos/slproweb/opensslhashes/contents/win32_openssl_hashes.json"
        $Headers = @{
          Accept="application/vnd.github.raw+json"
          Authorization="Bearer ${{ secrets.GITHUB_TOKEN }}"
        }
        $openSSL = (Invoke-RestMethod $VersionsUrl -Headers $Headers).files.PSObject.Properties |
          Select-Object -ExpandProperty Value |
          Where-Object { $_.arch -eq 'INTEL' } |
          Where-Object { $_.bits -eq '64' } |
          Where-Object { $_.light -eq $false } |
          Where-Object { $_.installer  -eq 'exe' } |
          Sort-Object -Descending @{ Expression = { [version]$_.basever } } |
          Select-Object -First 1
        [System.String]::Format("cache-key=openssl-{0}-win-{1}-{2}", $openSSL.basever, $openSSL.arch, $openSSL.bits) >> $env:GITHUB_OUTPUT
        [System.String]::Format("url={0}", $openSSL.url) >> $env:GITHUB_OUTPUT

    - name: Cache OpenSSL
      id: cache-openssl
      uses: actions/cache@v4
      with:
        path: ${{ env.OPENSSL_ROOT_DIR }}
        key: ${{ steps.openssl-info.outputs.cache-key }}

    - name: Download and install Openssl 3.x
      if: ${{ steps.cache-openssl.outputs.cache-hit != 'true' }}
      run: |
        (New-Object System.Net.WebClient).DownloadFile("${{ steps.openssl-info.outputs.url }}", "${{ env.TEMP }}\openssl.exe")
        Start-Process -Wait -FilePath "${{ env.TEMP }}\openssl.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES",/DIR=${{ env.OPENSSL_ROOT_DIR }}

        # Quick Openssl install test
        & ${{ env.OPENSSL_ROOT_DIR }}/bin/openssl.exe version

    - name: Download and install Boost
      uses: MarkusJx/install-boost@v2
      id: install-boost
      with:
        boost_version: 1.84.0
        link: static
        platform_version: 2022
        toolset: msvc

    - name: Initialize Visual Studio Environment
      uses: egor-tensin/vs-shell@v2
      with:
        arch: x64

    - name: Configure CMake
      env:
        BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
      run: >
        cmake -GNinja -S ${{ github.workspace }} -B ${{ steps.strings.outputs.build-output-dir }}
        -DWITH_WARNINGS_AS_ERRORS=ON -DTOOLS=ON

    - name: Build
      run: |
        cmake --build ${{ steps.strings.outputs.build-output-dir }}

    - name: Copy Dependencies
      run: |
        cd ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
        copy "${{ env.MYSQL_ROOT_DIR }}/lib/libmysql.dll" libmysql.dll
        copy "${{ env.OPENSSL_ROOT_DIR }}/bin/libssl-3-x64.dll" libssl-3-x64.dll
        copy "${{ env.OPENSSL_ROOT_DIR }}/bin/libcrypto-3-x64.dll" libcrypto-3-x64.dll
        copy "${{ env.OPENSSL_ROOT_DIR }}/bin/legacy.dll" legacy.dll
      
    - name: Check binaries
      run: |
        cd ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
        ./bnetserver --version
        ./worldserver --version

    - name: Upload Artifacts
      uses: actions/upload-artifact@v4
      with:
        path: ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
        name: TrinityCoreMasterWin64VS2022
        # Set a custom retention for artifacts
        #retention-days: 7