Skip to content

Commit 24e8397

Browse files
authored
Merge pull request #24 from weespin/experimental
I hope it doesn't flop
2 parents 10b049e + 3712658 commit 24e8397

File tree

101 files changed

+7300
-6288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+7300
-6288
lines changed

.github/workflows/build.yml

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
name: Build Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
prebuild:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.get_version.outputs.version }}
14+
run_windows: ${{ steps.check_flags.outputs.run_windows }}
15+
run_linux: ${{ steps.check_flags.outputs.run_linux }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Check Build Flags First
21+
id: check_flags
22+
run: |
23+
MESSAGE=$(git log -1 --pretty=%B)
24+
echo "Last commit message: $MESSAGE"
25+
26+
if echo "$MESSAGE" | grep -qE "\[skip-ci\]|\[no-ci\]"; then
27+
echo "Detected skip CI flag, setting both platforms to false"
28+
echo "run_linux=false" >> $GITHUB_OUTPUT
29+
echo "run_windows=false" >> $GITHUB_OUTPUT
30+
echo "skip_version_bump=true" >> $GITHUB_OUTPUT
31+
else
32+
if echo "$MESSAGE" | grep -q "\[no-linux\]"; then
33+
echo "Skipping Linux build"
34+
echo "run_linux=false" >> $GITHUB_OUTPUT
35+
else
36+
echo "Running Linux build"
37+
echo "run_linux=true" >> $GITHUB_OUTPUT
38+
fi
39+
40+
if echo "$MESSAGE" | grep -q "\[no-win\]"; then
41+
echo "Skipping Windows build"
42+
echo "run_windows=false" >> $GITHUB_OUTPUT
43+
else
44+
echo "Running Windows build"
45+
echo "run_windows=true" >> $GITHUB_OUTPUT
46+
fi
47+
echo "skip_version_bump=false" >> $GITHUB_OUTPUT
48+
fi
49+
50+
- name: Increment APP_VERSION
51+
if: steps.check_flags.outputs.skip_version_bump != 'true'
52+
run: |
53+
VERSION=$(cat APP_VERSION)
54+
BASE=$(echo "$VERSION" | sed 's/-.*//')
55+
SUFFIX=$(echo "$VERSION" | grep -oP '(?<=-).*' || echo "")
56+
IFS='.' read -r -a PARTS <<< "$BASE"
57+
58+
LAST_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
59+
60+
if echo "$LAST_COMMIT_MESSAGE" | grep -q "\[MAJOR\]"; then
61+
PARTS[0]=$((PARTS[0]+1))
62+
PARTS[1]=0
63+
PARTS[2]=0
64+
elif echo "$LAST_COMMIT_MESSAGE" | grep -q "\[MINOR\]"; then
65+
PARTS[1]=$((PARTS[1]+1))
66+
PARTS[2]=0
67+
elif echo "$LAST_COMMIT_MESSAGE" | grep -q "\[PATCH\]"; then
68+
PARTS[2]=$((PARTS[2]+1))
69+
fi
70+
71+
PARTS[3]=$((PARTS[3]+1)) # always bump build number
72+
73+
NEW_VERSION="${PARTS[0]}.${PARTS[1]}.${PARTS[2]}.${PARTS[3]}"
74+
if [ -n "$SUFFIX" ]; then
75+
NEW_VERSION="$NEW_VERSION-$SUFFIX"
76+
fi
77+
echo "$NEW_VERSION" > APP_VERSION
78+
79+
- name: Bump resource.rc
80+
if: steps.check_flags.outputs.skip_version_bump != 'true'
81+
run: |
82+
cd scripts/shared
83+
python3 updateversion.py
84+
cd ../..
85+
86+
- name: Commit updated APP_VERSION
87+
if: steps.check_flags.outputs.skip_version_bump != 'true'
88+
run: |
89+
git config user.name "github-actions[bot]"
90+
git config user.email "github-actions[bot]@users.noreply.github.com"
91+
git add APP_VERSION
92+
git add resource.rc
93+
git commit -m "ci: bump version"
94+
git push
95+
96+
- name: Get Version
97+
id: get_version
98+
run: |
99+
echo "version=$(cat APP_VERSION)" >> $GITHUB_OUTPUT
100+
101+
windows_build:
102+
needs: prebuild
103+
if: needs.prebuild.outputs.run_windows == 'true'
104+
runs-on: windows-latest
105+
steps:
106+
- name: Set VCPKG env
107+
run: |
108+
echo "VCPKG_ROOT=C:\vcpkg" >> $env:GITHUB_ENV
109+
echo "VCPKG_DEFAULT_TRIPLET=x64-windows" >> $env:GITHUB_ENV
110+
111+
- name: Export GitHub Actions cache variables
112+
uses: actions/github-script@v7
113+
with:
114+
script: |
115+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
116+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
117+
118+
- name: Checkout repository
119+
uses: actions/checkout@v2
120+
121+
- name: Cache Qt
122+
uses: actions/cache@v4
123+
with:
124+
path: '${{ env.TEMP }}\qt'
125+
key: windows-qt-${{ hashFiles('**/CMakeLists.txt') }}
126+
restore-keys: |
127+
windows-qt-
128+
129+
- name: Install Qt 6.8.3
130+
uses: jurplel/install-qt-action@v4
131+
with:
132+
version: '6.8.3'
133+
target: 'desktop'
134+
dir: '${{ env.TEMP }}\qt'
135+
modules: 'qt5compat qtshadertools'
136+
arch: 'win64_msvc2022_64'
137+
138+
- name: Cache CMake dependencies
139+
uses: actions/cache@v4
140+
with:
141+
path: build/.cmake
142+
key: windows-cmake-${{ hashFiles('**/CMakeLists.txt') }}
143+
restore-keys: |
144+
windows-cmake-
145+
146+
- name: Update VCPKG Baseline
147+
run: |
148+
& "C:\vcpkg\vcpkg.exe" x-update-baseline
149+
150+
- name: Build with CMake
151+
env:
152+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
153+
run: |
154+
mkdir build
155+
cd build
156+
cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release
157+
cmake --build . --config Release
158+
cd ..
159+
160+
- name: Run windeployqt
161+
run: |
162+
&"D:\qt\Qt\6.8.3\msvc2022_64\bin\windeployqt.exe" --qmldir src\ui --no-translations --release --force-openssl build\Release\appKhinsiderQT.exe
163+
164+
- name: Download INNO SETUP
165+
run: |
166+
choco install innosetup
167+
168+
- name: Create Installer
169+
run: |
170+
cd scripts\windows
171+
.\createInstaller.bat
172+
cd ..\..
173+
174+
- name: Upload artifacts
175+
uses: actions/upload-artifact@v4
176+
with:
177+
name: windows-release-${{ needs.prebuild.outputs.version }}
178+
path: build/Release/*
179+
180+
- name: Upload Installer
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: windows-installer-${{ needs.prebuild.outputs.version }}
184+
path: build/Installer/KhinsiderInstaller.exe
185+
186+
linux_build:
187+
needs: prebuild
188+
if: needs.prebuild.outputs.run_linux == 'true'
189+
runs-on: ubuntu-latest
190+
steps:
191+
- name: Checkout repository
192+
uses: actions/checkout@v2
193+
194+
- name: Cache Qt
195+
uses: actions/cache@v4
196+
with:
197+
path: '${{ runner.temp }}/qt'
198+
key: ${{ runner.os }}-qt-${{ hashFiles('**/CMakeLists.txt') }}
199+
restore-keys: |
200+
${{ runner.os }}-qt-
201+
202+
- name: Install Qt
203+
uses: jurplel/install-qt-action@v4
204+
with:
205+
version: '6.8.3'
206+
target: 'desktop'
207+
dir: '${{ runner.temp }}/qt'
208+
modules: 'qt5compat qtshadertools'
209+
210+
- name: Cache CMake dependencies
211+
uses: actions/cache@v4
212+
with:
213+
path: build/.cmake
214+
key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
215+
restore-keys: |
216+
${{ runner.os }}-cmake-
217+
218+
- name: Install dependencies
219+
run: sudo apt-get update && sudo apt-get install -y build-essential cmake libcurl4-openssl-dev
220+
221+
- name: Build with CMake
222+
run: |
223+
mkdir build
224+
cd build
225+
cmake ..
226+
make
227+
cd ..
228+
229+
- name: RunDeploy
230+
run: |
231+
chmod +x ./scripts/linux/deploy.sh
232+
./scripts/linux/deploy.sh
233+
234+
- name: Send Artifact
235+
uses: actions/upload-artifact@v4
236+
with:
237+
name: linux-release-${{ needs.prebuild.outputs.version }}
238+
path: deploy/result/KhinsiderQT*.AppImage
239+
240+
postbuild:
241+
needs: [prebuild, windows_build, linux_build]
242+
if: |
243+
always() &&
244+
(needs.prebuild.outputs.run_windows == 'false' || needs.windows_build.result == 'success') &&
245+
(needs.prebuild.outputs.run_linux == 'false' || needs.linux_build.result == 'success')
246+
runs-on: ubuntu-latest
247+
steps:
248+
- name: Checkout repository
249+
uses: actions/checkout@v2
250+
with:
251+
fetch-depth: 0
252+
253+
- name: Check for RELEASE or PRE-RELEASE in commit message
254+
id: check_release
255+
run: |
256+
COMMIT_MESSAGE=$(git log -2 --pretty=%B)
257+
if echo "$COMMIT_MESSAGE" | grep -q "\[RELEASE\]"; then
258+
echo "create_release=true" >> $GITHUB_OUTPUT
259+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
260+
elif echo "$COMMIT_MESSAGE" | grep -q "\[PRE-RELEASE\]"; then
261+
echo "create_release=true" >> $GITHUB_OUTPUT
262+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
263+
else
264+
echo "create_release=false" >> $GITHUB_OUTPUT
265+
fi
266+
267+
- name: Get version from APP_VERSION
268+
id: get_version
269+
if: steps.check_release.outputs.create_release == 'true'
270+
run: |
271+
VERSION=$(cat APP_VERSION)
272+
CLEAN_VERSION=$(echo "$VERSION" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
273+
echo "version=$CLEAN_VERSION" >> $GITHUB_OUTPUT
274+
echo "tag_version=v$CLEAN_VERSION" >> $GITHUB_OUTPUT
275+
276+
- name: Download all artifacts
277+
if: steps.check_release.outputs.create_release == 'true'
278+
uses: actions/download-artifact@v4
279+
with:
280+
path: release-artifacts
281+
282+
- name: Prepare release assets
283+
if: steps.check_release.outputs.create_release == 'true'
284+
run: |
285+
mkdir -p release-assets
286+
287+
if [ -d "release-artifacts/linux-release-${{ needs.prebuild.outputs.version }}" ]; then
288+
cd release-artifacts/linux-release-${{ needs.prebuild.outputs.version }}
289+
find . -name "*.zip" -exec unzip {} \;
290+
find . -name "*.AppImage" -exec cp {} ../../release-assets/ \;
291+
cd ../..
292+
fi
293+
294+
# Copy Windows installer to release assets
295+
if [ -d "release-artifacts/windows-installer-${{ needs.prebuild.outputs.version }}" ]; then
296+
cp release-artifacts/windows-installer-${{ needs.prebuild.outputs.version }}/KhinsiderInstaller.exe release-assets/KhinsiderInstaller-${{ steps.get_version.outputs.version }}.exe
297+
fi
298+
299+
# List all prepared assets
300+
ls -la release-assets/
301+
302+
- name: Create Release
303+
if: steps.check_release.outputs.create_release == 'true'
304+
uses: softprops/action-gh-release@v1
305+
with:
306+
tag_name: ${{ steps.get_version.outputs.tag_version }}
307+
name: "Release: ${{ steps.get_version.outputs.version }}"
308+
body: "To be filled"
309+
prerelease: ${{ steps.check_release.outputs.is_prerelease }}
310+
files: |
311+
release-assets/*
312+
env:
313+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)