-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·123 lines (112 loc) · 4.04 KB
/
cmake-multi-platform.yml
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
name: Build and Release
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_extension: tar.gz
- os: macos-latest
artifact_extension: zip
- os: windows-latest
artifact_extension: zip
steps:
- name: Checkout code
uses: actions/checkout@v4
# Windows Section
- name: Check Visual Studio Build Tools Path
if: matrix.os == 'windows-latest'
run: |
Write-Host "Checking for Visual Studio Build Tools..."
$vcvarsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
if (!(Test-Path $vcvarsPath)) {
Write-Host "Visual Studio Build Tools not found at $vcvarsPath"
exit 1
} else {
Write-Host "Found Visual Studio Build Tools at $vcvarsPath"
}
shell: pwsh
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install qt --version=6.5.3 -y
choco install ninja -y
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
choco install visualstudio2022buildtools -y --install-arguments \
'--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --norestart'
- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: |
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cmake -B D:\a\Notepad--\Notepad--\build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_PREFIX_PATH="C:\Qt\6.5.3\msvc2019_64\lib\cmake" `
-G Ninja `
-S D:\a\Notepad--\Notepad--
shell: pwsh
- name: Build application (Windows)
if: matrix.os == 'windows-latest'
run: |
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cmake --build D:\a\Notepad--\Notepad--\build --config Release
shell: pwsh
- name: Package application (Windows)
if: matrix.os == 'windows-latest'
run: |
cd D:\a\Notepad--\Notepad--\build
Compress-Archive -Path . -DestinationPath application.zip
shell: pwsh
# Other Platforms Sections
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build \
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \
qt6-l10n-tools libgl1-mesa-dev libglu1-mesa-dev rsync
- name: Configure CMake (Ubuntu and macOS)
if: matrix.os != 'windows-latest'
run: |
cmake -B "${{ github.workspace }}/build" \
-DCMAKE_BUILD_TYPE=Release \
-G "Ninja" \
-S "${{ github.workspace }}"
shell: bash
- name: Build application (Ubuntu and macOS)
if: matrix.os != 'windows-latest'
run: cmake --build "${{ github.workspace }}/build" --config Release
shell: bash
- name: Package application (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
BUILD_DIR="${{ github.workspace }}/build"
TEMP_DIR="/tmp/build_copy"
rm -rf $TEMP_DIR
rsync -a "$BUILD_DIR/" "$TEMP_DIR/"
cd $TEMP_DIR
tar -czvf application.tar.gz ./*
- name: Package application (macOS)
if: matrix.os == 'macos-latest'
run: |
cd "${{ github.workspace }}/build"
hdiutil create -volname Application -srcfolder . -ov -format UDZO application.dmg
zip application.zip application.dmg
# Upload Artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: application-${{ matrix.os }}
path: |
${{ github.workspace }}/build/application.${{ matrix.artifact_extension }}
/tmp/build_copy/application.tar.gz