Skip to content

Commit 0db42a8

Browse files
committed
Refactor CI workflow
1 parent 914ebf2 commit 0db42a8

File tree

1 file changed

+88
-119
lines changed

1 file changed

+88
-119
lines changed

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

Lines changed: 88 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ 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

8+
permissions:
9+
contents: write
10+
1211
env:
1312
CMAKE_VERSION: "3.28.0"
1413
QT_VERSION: "6.9.3"
@@ -19,189 +18,159 @@ jobs:
1918
fail-fast: false
2019
matrix:
2120
include:
22-
# Windows MSVC builds
2321
- name: "Windows MSVC 2022 x64"
2422
os: windows-2022
2523
preset: "windows-msvc-x64-release"
26-
cmake_generator: "Visual Studio 17 2022"
27-
cmake_platform: "x64"
24+
generator: "Visual Studio 17 2022"
25+
platform: "x64"
2826
qt_arch: "win64_msvc2022_64"
2927
artifact_prefix: "windows-msvc-x64"
3028

31-
# macOS builds
3229
- name: "macOS x86_64 (Intel)"
3330
os: macos-13
3431
preset: "macos-x64-release"
35-
cmake_generator: "Ninja"
36-
cmake_build_type: "Release"
32+
generator: "Ninja"
33+
build_type: "Release"
3734
qt_arch: "clang_64"
3835
artifact_prefix: "macos-x64"
3936

40-
# Linux builds
4137
- name: "Linux x64"
4238
os: ubuntu-22.04
4339
preset: "linux-x64-release"
44-
cmake_generator: "Ninja"
45-
cmake_build_type: "Release"
40+
generator: "Ninja"
41+
build_type: "Release"
4642
qt_arch: "linux_gcc_64"
4743
artifact_prefix: "linux-x64"
4844

49-
# ARM Linux builds
5045
- name: "ARM Linux (aarch64)"
5146
os: ubuntu-22.04
5247
preset: "linux-arm64-release"
53-
cmake_generator: "Ninja"
54-
cmake_build_type: "Release"
48+
generator: "Ninja"
49+
build_type: "Release"
5550
qt_arch: "linux_gcc_arm64"
5651
artifact_prefix: "linux-arm64"
5752

5853
runs-on: ${{ matrix.os }}
5954
name: ${{ matrix.name }}
6055

6156
steps:
62-
- name: Checkout code
57+
- name: Checkout repository
6358
uses: actions/checkout@v4
6459
with:
6560
fetch-depth: 0
6661

67-
- name: Install Qt (Windows)
62+
# Dependencies
63+
- name: Install dependencies
64+
run: |
65+
if [ "${{ runner.os }}" == "Linux" ]; then
66+
sudo apt-get update
67+
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
68+
elif [ "${{ runner.os }}" == "macOS" ]; then
69+
brew install ninja cmake
70+
fi
71+
shell: bash
72+
73+
- name: Install dependencies (Windows)
6874
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'
75+
run: choco install ninja cmake -y
7476

75-
- name: Install Qt (macOS)
76-
if: runner.os == 'macOS'
77+
# Qt setup
78+
- name: Install Qt (Windows/macOS)
79+
if: runner.os != 'Linux'
7780
uses: jurplel/install-qt-action@v4
7881
with:
7982
version: ${{ env.QT_VERSION }}
8083
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
84+
cache: true
9885

99-
- name: Install dependencies (Linux)
100-
if: runner.os == 'Linux'
86+
# 🏗Build
87+
- name: Configure CMake
10188
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-
..
89+
cmake -E make_directory build
90+
cd build
91+
if [ "${{ runner.os }}" == "Windows" ]; then
92+
cmake -G "${{ matrix.generator }}" -A ${{ matrix.platform }} \
93+
-DCMAKE_BUILD_TYPE=Release \
94+
-DBUILD_EXAMPLES=ON \
95+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
96+
..
97+
else
98+
cmake -G "${{ matrix.generator }}" \
99+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
100+
-DBUILD_EXAMPLES=ON \
101+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
102+
..
103+
fi
104+
shell: bash
129105

130106
- name: Build
131-
run: cmake --build ${{ github.workspace }}/build --config Release --parallel
107+
run: cmake --build build --config Release --parallel
132108

133109
- 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
110+
run: cmake --install build --config Release
142111

143-
- name: Create package (macOS)
144-
if: runner.os == 'macOS'
112+
# Packaging
113+
- name: Package artifacts
145114
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
115+
cd build
116+
case "${{ runner.os }}" in
117+
Windows)
118+
cpack -C Release -G NSIS
119+
;;
120+
macOS)
121+
cpack -C Release -G DragNDrop
122+
cpack -C Release -G TGZ
123+
;;
124+
Linux)
125+
cpack -C Release -G DEB
126+
cpack -C Release -G RPM
127+
cpack -C Release -G TGZ
128+
;;
129+
esac
130+
shell: bash
131+
132+
# Upload packages
133+
- name: Upload build artifacts
159134
uses: actions/upload-artifact@v4
160135
with:
161136
name: ${{ matrix.artifact_prefix }}-packages
162-
path: ${{ github.workspace }}/build/QTradingView-*
137+
path: build/QTradingView-*
163138
retention-days: 30
164139

165-
- name: Generate checksums (Windows)
166-
if: runner.os == 'Windows'
167-
shell: pwsh
140+
# Checksums
141+
- name: Generate checksums
168142
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/')
143+
cd build
144+
if [ "${{ runner.os }}" == "Windows" ]; then
145+
pwsh -Command 'Get-ChildItem -File "QTradingView-*" | ForEach-Object { Get-FileHash $_.FullName -Algorithm SHA256 | ForEach-Object { $_.Hash | Out-File ($_.Path + ".sha256") -Encoding ascii } }'
146+
else
147+
find . -maxdepth 1 -name "QTradingView-*" -type f -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \;
148+
fi
149+
shell: bash
150+
151+
- name: Upload checksum files
183152
uses: actions/upload-artifact@v4
184153
with:
185154
name: ${{ matrix.artifact_prefix }}-checksums
186-
path: ${{ github.workspace }}/build/*.sha256
155+
path: build/*.sha256
187156
retention-days: 30
188157

189158
release:
190159
needs: build
191160
runs-on: ubuntu-latest
192-
# if: startsWith(github.ref, 'refs/tags/')
193-
name: Create Release
161+
name: Create GitHub Release
162+
if: startsWith(github.ref, 'refs/tags/')
194163

195164
steps:
196-
- name: Checkout code
165+
- name: Checkout repository
197166
uses: actions/checkout@v4
198167

199168
- name: Download all artifacts
200169
uses: actions/download-artifact@v4
201170
with:
202171
path: artifacts
203172

204-
- name: Create Release
173+
- name: Create GitHub Release
205174
uses: softprops/action-gh-release@v1
206175
with:
207176
draft: false

0 commit comments

Comments
 (0)