Skip to content

Commit 8b7d2b5

Browse files
committed
Refactor CI workflow
1 parent 914ebf2 commit 8b7d2b5

File tree

1 file changed

+85
-119
lines changed

1 file changed

+85
-119
lines changed

.github/workflows/build-and-release.yml

Lines changed: 85 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ name: Build and Release
22

33
on:
44
push:
5-
branches: [ main, develop ]
6-
tags:
7-
- 'v*'
8-
pull_request:
9-
branches: [ main, develop ]
5+
tags: [ 'v*' ]
106
workflow_dispatch:
117

128
env:
@@ -19,189 +15,159 @@ jobs:
1915
fail-fast: false
2016
matrix:
2117
include:
22-
# Windows MSVC builds
2318
- name: "Windows MSVC 2022 x64"
2419
os: windows-2022
2520
preset: "windows-msvc-x64-release"
26-
cmake_generator: "Visual Studio 17 2022"
27-
cmake_platform: "x64"
21+
generator: "Visual Studio 17 2022"
22+
platform: "x64"
2823
qt_arch: "win64_msvc2022_64"
2924
artifact_prefix: "windows-msvc-x64"
3025

31-
# macOS builds
3226
- name: "macOS x86_64 (Intel)"
3327
os: macos-13
3428
preset: "macos-x64-release"
35-
cmake_generator: "Ninja"
36-
cmake_build_type: "Release"
29+
generator: "Ninja"
30+
build_type: "Release"
3731
qt_arch: "clang_64"
3832
artifact_prefix: "macos-x64"
3933

40-
# Linux builds
4134
- name: "Linux x64"
4235
os: ubuntu-22.04
4336
preset: "linux-x64-release"
44-
cmake_generator: "Ninja"
45-
cmake_build_type: "Release"
37+
generator: "Ninja"
38+
build_type: "Release"
4639
qt_arch: "linux_gcc_64"
4740
artifact_prefix: "linux-x64"
4841

49-
# ARM Linux builds
5042
- name: "ARM Linux (aarch64)"
5143
os: ubuntu-22.04
5244
preset: "linux-arm64-release"
53-
cmake_generator: "Ninja"
54-
cmake_build_type: "Release"
45+
generator: "Ninja"
46+
build_type: "Release"
5547
qt_arch: "linux_gcc_arm64"
5648
artifact_prefix: "linux-arm64"
5749

5850
runs-on: ${{ matrix.os }}
5951
name: ${{ matrix.name }}
6052

6153
steps:
62-
- name: Checkout code
54+
- name: Checkout repository
6355
uses: actions/checkout@v4
6456
with:
6557
fetch-depth: 0
6658

67-
- name: Install Qt (Windows)
59+
# Dependencies
60+
- name: Install dependencies
61+
run: |
62+
if [ "${{ runner.os }}" == "Linux" ]; then
63+
sudo apt-get update
64+
sudo apt-get install -y ninja-build cmake build-essential libgl1-mesa-dev libglu1-mesa-dev libegl1-mesa-dev qt6-base-dev qt6-base-dev-tools
65+
elif [ "${{ runner.os }}" == "macOS" ]; then
66+
brew install ninja cmake
67+
fi
68+
shell: bash
69+
70+
- name: Install dependencies (Windows)
6871
if: runner.os == 'Windows'
69-
uses: jurplel/install-qt-action@v4
70-
with:
71-
version: ${{ env.QT_VERSION }}
72-
arch: ${{ matrix.qt_arch }}
73-
cache: 'true'
72+
run: choco install ninja cmake -y
7473

75-
- name: Install Qt (macOS)
76-
if: runner.os == 'macOS'
74+
# Qt setup
75+
- name: Install Qt (Windows/macOS)
76+
if: runner.os != 'Linux'
7777
uses: jurplel/install-qt-action@v4
7878
with:
7979
version: ${{ env.QT_VERSION }}
8080
arch: ${{ matrix.qt_arch }}
81-
cache: 'true'
82-
83-
- name: Install Qt (Linux)
84-
if: runner.os == 'Linux'
85-
run: |
86-
sudo apt-get update
87-
sudo apt-get install -y qt6-base-dev qt6-base-dev-tools
88-
89-
- name: Install dependencies (Windows)
90-
if: runner.os == 'Windows'
91-
run: |
92-
choco install ninja cmake -y
93-
94-
- name: Install dependencies (macOS)
95-
if: runner.os == 'macOS'
96-
run: |
97-
brew install ninja cmake
81+
cache: true
9882

99-
- name: Install dependencies (Linux)
100-
if: runner.os == 'Linux'
83+
# 🏗Build
84+
- name: Configure CMake
10185
run: |
102-
sudo apt-get update
103-
sudo apt-get install -y ninja-build cmake build-essential libgl1-mesa-dev libglu1-mesa-dev libegl1-mesa-dev
104-
105-
- name: Create build directory
106-
run: cmake -E make_directory ${{ github.workspace }}/build
107-
108-
- name: Configure CMake (Windows)
109-
if: runner.os == 'Windows'
110-
shell: cmd
111-
run: |
112-
cd ${{ github.workspace }}/build
113-
cmake -G "${{ matrix.cmake_generator }}" ^
114-
-A ${{ matrix.cmake_platform }} ^
115-
-DCMAKE_BUILD_TYPE=Release ^
116-
-DBUILD_EXAMPLES=ON ^
117-
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" ^
118-
..
119-
120-
- name: Configure CMake (non-Windows)
121-
if: runner.os != 'Windows'
122-
run: |
123-
cd ${{ github.workspace }}/build
124-
cmake -G "${{ matrix.cmake_generator }}" \
125-
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
126-
-DBUILD_EXAMPLES=ON \
127-
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
128-
..
86+
cmake -E make_directory build
87+
cd build
88+
if [ "${{ runner.os }}" == "Windows" ]; then
89+
cmake -G "${{ matrix.generator }}" -A ${{ matrix.platform }} \
90+
-DCMAKE_BUILD_TYPE=Release \
91+
-DBUILD_EXAMPLES=ON \
92+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
93+
..
94+
else
95+
cmake -G "${{ matrix.generator }}" \
96+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
97+
-DBUILD_EXAMPLES=ON \
98+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
99+
..
100+
fi
101+
shell: bash
129102

130103
- name: Build
131-
run: cmake --build ${{ github.workspace }}/build --config Release --parallel
104+
run: cmake --build build --config Release --parallel
132105

133106
- name: Install
134-
run: cmake --install ${{ github.workspace }}/build --config Release
135-
136-
- name: Create package (Windows)
137-
if: runner.os == 'Windows'
138-
shell: cmd
139-
run: |
140-
cd ${{ github.workspace }}/build
141-
cpack -C Release -G NSIS
107+
run: cmake --install build --config Release
142108

143-
- name: Create package (macOS)
144-
if: runner.os == 'macOS'
109+
# Packaging
110+
- name: Package artifacts
145111
run: |
146-
cd ${{ github.workspace }}/build
147-
cpack -C Release -G DragNDrop
148-
cpack -C Release -G TGZ
149-
150-
- name: Create package (Linux)
151-
if: runner.os == 'Linux'
152-
run: |
153-
cd ${{ github.workspace }}/build
154-
cpack -C Release -G DEB
155-
cpack -C Release -G RPM
156-
cpack -C Release -G TGZ
157-
158-
- name: Upload artifacts
112+
cd build
113+
case "${{ runner.os }}" in
114+
Windows)
115+
cpack -C Release -G NSIS
116+
;;
117+
macOS)
118+
cpack -C Release -G DragNDrop
119+
cpack -C Release -G TGZ
120+
;;
121+
Linux)
122+
cpack -C Release -G DEB
123+
cpack -C Release -G RPM
124+
cpack -C Release -G TGZ
125+
;;
126+
esac
127+
shell: bash
128+
129+
# Upload packages
130+
- name: Upload build artifacts
159131
uses: actions/upload-artifact@v4
160132
with:
161133
name: ${{ matrix.artifact_prefix }}-packages
162-
path: ${{ github.workspace }}/build/QTradingView-*
134+
path: build/QTradingView-*
163135
retention-days: 30
164136

165-
- name: Generate checksums (Windows)
166-
if: runner.os == 'Windows'
167-
shell: pwsh
137+
# Checksums
138+
- name: Generate checksums
168139
run: |
169-
Get-ChildItem -File "QTradingView-*" | ForEach-Object {
170-
Get-FileHash $_.FullName -Algorithm SHA256 |
171-
ForEach-Object { $_.Hash | Out-File ($_.Path + ".sha256") -Encoding ascii }
172-
}
173-
174-
- name: Generate checksums (Linux/macOS)
175-
if: runner.os != 'Windows'
176-
run: |
177-
cd ${{ github.workspace }}/build
178-
find . -maxdepth 1 -name "QTradingView-*" -type f -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \;
179-
180-
181-
- name: Upload checksums
182-
# if: startsWith(github.ref, 'refs/tags/')
140+
cd build
141+
if [ "${{ runner.os }}" == "Windows" ]; then
142+
pwsh -Command 'Get-ChildItem -File "QTradingView-*" | ForEach-Object { Get-FileHash $_.FullName -Algorithm SHA256 | ForEach-Object { $_.Hash | Out-File ($_.Path + ".sha256") -Encoding ascii } }'
143+
else
144+
find . -maxdepth 1 -name "QTradingView-*" -type f -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \;
145+
fi
146+
shell: bash
147+
148+
- name: Upload checksum files
183149
uses: actions/upload-artifact@v4
184150
with:
185151
name: ${{ matrix.artifact_prefix }}-checksums
186-
path: ${{ github.workspace }}/build/*.sha256
152+
path: build/*.sha256
187153
retention-days: 30
188154

189155
release:
190156
needs: build
191157
runs-on: ubuntu-latest
192-
# if: startsWith(github.ref, 'refs/tags/')
193-
name: Create Release
158+
name: Create GitHub Release
159+
if: startsWith(github.ref, 'refs/tags/')
194160

195161
steps:
196-
- name: Checkout code
162+
- name: Checkout repository
197163
uses: actions/checkout@v4
198164

199165
- name: Download all artifacts
200166
uses: actions/download-artifact@v4
201167
with:
202168
path: artifacts
203169

204-
- name: Create Release
170+
- name: Create GitHub Release
205171
uses: softprops/action-gh-release@v1
206172
with:
207173
draft: false

0 commit comments

Comments
 (0)