|
| 1 | +name: release build |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: windows-2022 |
| 10 | + steps: |
| 11 | + # Cloning all repository recursively |
| 12 | + - name: Get Sources |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + submodules: true |
| 16 | + |
| 17 | + # Check this about more info: https://github.com/marketplace/actions/install-version-specific-mingw |
| 18 | + # Setting up MinGW_x64 version 8.1.0 |
| 19 | + - name: Set Up MinGW |
| 20 | + uses: egor-tensin/setup-mingw@v2 |
| 21 | + with: |
| 22 | + platform: x64 |
| 23 | + version: 12.2.0 |
| 24 | + |
| 25 | + # Check this about more info: https://github.com/marketplace/actions/install-qt |
| 26 | + # This action cannot download needed mingw810 |
| 27 | + # So it downloads only Qt part |
| 28 | + - name: Set Up Qt |
| 29 | + uses: jurplel/install-qt-action@v3 |
| 30 | + with: |
| 31 | + version: 5.15.2 |
| 32 | + arch: win64_mingw81 |
| 33 | + target: desktop |
| 34 | + dir: C:\ |
| 35 | + |
| 36 | + # Check this about more info: https://github.com/marketplace/actions/cmake-action |
| 37 | + - name: Set Up CMake |
| 38 | + |
| 39 | + with: |
| 40 | + run-build: false |
| 41 | + |
| 42 | + # Compile code |
| 43 | + - name: Compile Project |
| 44 | + shell: cmd |
| 45 | + run: | |
| 46 | + :: Remove previous cmake build folder |
| 47 | + |
| 48 | + rmdir /s /q build >nul 2>nul |
| 49 | + :: Link MinGW to system variables |
| 50 | + mkdir C:\Qt\Tools > nul |
| 51 | + mklink C:\Qt\Tools\mingw_64 C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64 > nul |
| 52 | + set PATH=%PATH%;C:\Qt\5.15.2\mingw81_64\bin;C:\Qt\Tools\mingw_64\bin |
| 53 | + |
| 54 | + :: Print header |
| 55 | + echo Program: GenHotkeys |
| 56 | + echo Authors: mah_boi, nikitvs |
| 57 | + echo. |
| 58 | +
|
| 59 | + :: Set up cmake config folder for the project |
| 60 | + echo Configuring MinGW Make... |
| 61 | + cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\Qt\Tools\mingw_64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\Qt\Tools\mingw_64\bin\g++.exe -S.\ -B.\build -G "MinGW Makefiles" |
| 62 | + echo Configuring MinGW Make done |
| 63 | + echo. |
| 64 | +
|
| 65 | + :: Start compiling |
| 66 | + echo Compilation and linking executables... |
| 67 | + cmake --build .\build --config Release --target all -j 16 |
| 68 | + echo Compilation and linking executables done |
| 69 | + echo. |
| 70 | +
|
| 71 | + :: Add any file to "Logs" folder for the next shipping |
| 72 | + mkdir build\exe\Logs >nul 2> nul |
| 73 | + cd build\exe\Logs |
| 74 | + echo Do not delete this folder, please. Or program will can not be start. > readme.txt |
| 75 | +
|
| 76 | + # Check if workflow has been called for release |
| 77 | + - name: Development Build Check |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + if ($env:GitVersion_CommitsSinceVersionSource -ne "0") { |
| 81 | + Write-Output "::error:: This is a development build and should not be released. Did you forget to create a new tag for the release?" |
| 82 | + exit 1 |
| 83 | + } |
| 84 | +
|
| 85 | + # Compress folder |
| 86 | + - name: Zip Artifact |
| 87 | + run: 7z a -t7z -mx=9 -m0=lzma2 -ms=on -r -- ${{ format('GenHotkeys-{0}.7z', env.GitVersion_SemVer) }} ./build/exe/* |
| 88 | + shell: pwsh |
| 89 | + |
| 90 | + # Upload it to release |
| 91 | + - name: Upload Final Artifact to the Release |
| 92 | + uses: softprops/action-gh-release@v2 |
| 93 | + with: |
| 94 | + append_body: true |
| 95 | + files: ${{ format('GenHotkeys-{0}.7z', env.GitVersion_SemVer) }} |
0 commit comments