Skip to content

Commit 9ae3680

Browse files
committed
Add dev-build workflow
1 parent 05aa747 commit 9ae3680

File tree

6 files changed

+207
-17
lines changed

6 files changed

+207
-17
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Initialize building environment
2+
description: Initialize building environment
3+
4+
inputs:
5+
qt_version:
6+
description: Qt version to install
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
12+
steps:
13+
- name: Setup devcmd
14+
if: runner.os == 'Windows'
15+
uses: ilammy/msvc-dev-cmd@v1
16+
17+
- name: Install build tools (Windows)
18+
if: runner.os == 'Windows'
19+
shell: pwsh
20+
run: |
21+
choco install innosetup
22+
23+
- name: Install build tools (Ubuntu)
24+
if: runner.os == 'Linux'
25+
shell: pwsh
26+
run: |
27+
sudo apt update
28+
sudo apt-get -y install `
29+
ninja-build `
30+
libasound2-dev libatopology-dev `
31+
libxrandr-dev libxinerama-dev libxrender-dev libxcomposite-dev libxcursor-dev `
32+
libgl1-mesa-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libzstd-dev
33+
34+
- name: Install build tools (macOS)
35+
if: runner.os == 'macOS'
36+
shell: pwsh
37+
env:
38+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
39+
HOMEBREW_NO_INSTALL_CLEANUP: 1
40+
run: |
41+
brew update
42+
brew install ninja
43+
44+
- name: Install Qt
45+
uses: jurplel/install-qt-action@v4
46+
with:
47+
version: ${{ inputs.qt_version }}
48+
modules: qt5compat
49+
cache: true
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Initialize Vcpkg
2+
description: Initialize vcpkg
3+
4+
inputs:
5+
ref:
6+
description: "The ref to checkout"
7+
required: false
8+
default: "master"
9+
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Prepare vcpkg
15+
shell: pwsh
16+
run: |
17+
Write-Output VCPKG_DEFAULT_BINARY_CACHE=${{ github.workspace }}/vcpkg_archives >> $env:GITHUB_ENV
18+
19+
- name: Restore vcpkg binary cache
20+
id: cache_vcpkg
21+
uses: actions/cache/restore@v4
22+
with:
23+
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
24+
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}
25+
restore-keys: |
26+
${{ runner.os }}-vcpkg-${{ inputs.ref }}
27+
28+
- name: Install vcpkg dependencies
29+
env:
30+
QT_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6
31+
Qt6_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6
32+
VCPKG_CMAKE_RELEASE_BUILD_TYPE: "RelWithDebInfo"
33+
VCPKG_KEEP_ENV_VARS: "QT_DIR;Qt6_DIR;VCPKG_CMAKE_RELEASE_BUILD_TYPE"
34+
shell: pwsh
35+
run: |
36+
if (!(Test-Path $env:VCPKG_DEFAULT_BINARY_CACHE)) {
37+
New-Item $env:VCPKG_DEFAULT_BINARY_CACHE -ItemType directory
38+
}
39+
git clone https://github.com/microsoft/vcpkg.git
40+
Set-Location vcpkg
41+
git checkout ${{ inputs.ref }}
42+
${{ runner.os == 'Windows' && './bootstrap-vcpkg.bat' || 'sh ./bootstrap-vcpkg.sh' }}
43+
./vcpkg install `
44+
--x-manifest-root=${{ github.workspace }}/scripts/vcpkg-manifest `
45+
--x-install-root=./installed
46+
Write-Output VCPKG_ROOT_DIR=$(Resolve-Path .) >> $env:GITHUB_ENV
47+
48+
- name: Save vcpkg binary cache
49+
uses: actions/cache/save@v4
50+
with:
51+
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
52+
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}

.github/workflows/dev-build.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Dev Build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- 'README.md'
8+
- 'LICENSE'
9+
- 'crowdin.yml'
10+
- '.github/**'
11+
pull_request:
12+
branches:
13+
- main
14+
paths-ignore:
15+
- 'README.md'
16+
- 'LICENSE'
17+
- 'crowdin.yml'
18+
- '.github/**'
19+
workflow_dispatch:
20+
inputs:
21+
identifier:
22+
description: 'Version identifier'
23+
required: false
24+
type: string
25+
26+
defaults:
27+
run:
28+
shell: pwsh
29+
30+
jobs:
31+
Build:
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
os:
36+
- windows-2025
37+
# - ubuntu-24.04
38+
# - macos-15
39+
40+
env:
41+
QT_VERSION: 6.9.2
42+
VCPKG_REF: 7130194ed62c60c073aa08de01e8c06275dfefba
43+
INNOSETUP_REF: is-6_5_4
44+
VERSION_IDENTIFIER: ${{ github.sha }}${{ github.event.input.identifier && '.' || '' }}${{ github.event.input.identifier }}
45+
46+
runs-on: ${{ matrix.os }}
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
submodules: recursive
53+
54+
- name: Initialize building environment
55+
uses: ./.github/actions/initialize-build-environment
56+
with:
57+
qt_version: ${{ env.QT_VERSION }}
58+
59+
- name: Initialize Vcpkg
60+
uses: ./.github/actions/initialize-vcpkg
61+
with:
62+
ref: ${{ env.VCPKG_REF }}
63+
64+
- name: Build
65+
run: |
66+
$output = & ./scripts/ci/Build.ps1 -BuildType dev -VcpkgRootDir $env:VCPKG_ROOT_DIR -VersionIdentifier $env:VERSION_IDENTIFIER
67+
Write-Output ARTIFACT_NAME=$($output.ApplicationName)_$($output.Semver -replace '[\.\-\+]', '_') >> $env:GITHUB_ENV
68+
Write-Output BUILD_DIR=$($output.BuildDir) >> $env:GITHUB_ENV
69+
Write-Output INSTALLED_DIR=$($output.InstalledDir) >> $env:GITHUB_ENV
70+
Write-Output INSTALLER_FILE_BASE=$($output.InstallerFileBase) >> $env:GITHUB_ENV
71+
72+
- name: Collect symbol files
73+
run: |
74+
$output = & ./scripts/ci/Collect-Symbol-Files.ps1 -VcpkgRootDir $env:VCPKG_ROOT_DIR -InstalledDir $env:INSTALLED_DIR
75+
Write-Output SYMBOL_FILES_PATH=$($output.Path) >> $env:GITHUB_ENV
76+
77+
- name: Pack
78+
run: |
79+
$output = & ./scripts/ci/Pack.ps1 -BuildDir $env:BUILD_DIR -InstallerFileBase $env:INSTALLER_FILE_BASE -InnoSetupCommit $env:INNOSETUP_REF
80+
Write-Output PACKAGE_PATH=$($output.Path) >> $env:GITHUB_ENV
81+
82+
- name: Upload symbol files
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: ${{ env.ARTIFACT_NAME }}_symbol_files
86+
path: ${{ env.SYMBOL_FILES_PATH }}
87+
88+
- name: Upload package
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ env.ARTIFACT_NAME }}
92+
path: ${{ env.PACKAGE_PATH }}

scripts/ci/Build.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ param(
1111
)
1212

1313
if (-not (Test-Path $VcpkgRootDir)) {
14-
Write-Error "Vcpkg root directory does not exist: $VcpkgRootDir"
15-
exit 1
14+
throw "Vcpkg root directory does not exist: $VcpkgRootDir"
1615
}
1716

1817
Write-Host "Build type: $BuildType"
@@ -25,8 +24,7 @@ $cmakeContent = Get-Content $cmakeListsPath -Raw
2524
$projectMatch = [regex]::Match($cmakeContent, 'project\s*\(\s*(\w+)\s+VERSION\s+([\d.]+)')
2625

2726
if (-not $projectMatch.Success) {
28-
Write-Error "Could not find project declaration with VERSION in CMakeLists.txt"
29-
exit 1
27+
throw "Could not find project declaration with VERSION in CMakeLists.txt"
3028
}
3129

3230
$projectName = $projectMatch.Groups[1].Value
@@ -76,10 +74,10 @@ cmake -B build -G Ninja `
7674
"-DAPPLICATION_NAME=$applicationName" `
7775
"-DAPPLICATION_DISPLAY_NAME=$applicationDisplayName" `
7876
"-DAPPLICATION_SEMVER=$semver" `
79-
-DCMAKE_INSTALL_PREFIX=installed
77+
-DCMAKE_INSTALL_PREFIX=installed | Write-Host
8078

81-
cmake --build build --target all
82-
cmake --build build --target install
79+
cmake --build build --target all | Write-Host
80+
cmake --build build --target install | Write-Host
8381

8482
$buildResult = @{
8583
ProjectName = $projectName

scripts/ci/Collect-Symbol-Files.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ if ($IsWindows) {
1818
Push-Location $InstalledDir
1919
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { $_.Extension -eq '.exe' -or $_.Extension -eq '.dll' }
2020
foreach ($dllFile in $dllFiles) {
21-
dumpbin /PDBPATH:VERBOSE $dllFile.FullName
21+
dumpbin /PDBPATH:VERBOSE $dllFile.FullName | Write-Host
2222
$dumpbinOutput = dumpbin /PDBPATH $dllFile.FullName
2323
$matches = [regex]::Matches($dumpbinOutput, $PATTERN)
2424
if ($matches.Count -gt 0) {
2525
$pdbPath = $matches.Groups[1].Value
26-
Write-Output "$dllFile -> $pdbPath"
26+
Write-Host "$dllFile -> $pdbPath"
2727
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
2828
if (!(Test-Path $pdbTargetDirectory)) {
2929
New-Item $pdbTargetDirectory -ItemType directory
3030
}
3131
Copy-Item $pdbPath $pdbTargetDirectory
3232
} else {
33-
Write-Output "No PDB file: $dllFile"
33+
Write-Host "No PDB file: $dllFile"
3434
}
3535
}
3636
Pop-Location
@@ -40,15 +40,15 @@ if ($IsWindows) {
4040
foreach ($dllFile in $dllFiles) {
4141
$dsymutilOutput = dsymutil -s $dllFile.FullName
4242
if ($dsymutilOutput -match "N_OSO") {
43-
Write-Output "Copy and strip debug_info: $dllFile"
43+
Write-Host "Copy and strip debug_info: $dllFile"
4444
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
4545
if (!(Test-Path $pdbTargetDirectory)) {
4646
New-Item $pdbTargetDirectory -ItemType directory
4747
}
4848
dsymutil $dllFile.FullName -o "$pdbTargetDirectory/$($dllFile.Name).dSYM"
4949
strip -S $dllFile.FullName
5050
} else {
51-
Write-Output "Skip: $dllFile"
51+
Write-Host "Skip: $dllFile"
5252
}
5353
}
5454
Pop-Location
@@ -59,15 +59,15 @@ if ($IsWindows) {
5959
file $dllFile.FullName
6060
$fileOutput = file $dllFile.FullName
6161
if ($fileOutput -match "with debug_info") {
62-
Write-Output "Copy and strip debug_info: $dllFile"
62+
Write-Host "Copy and strip debug_info: $dllFile"
6363
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
6464
if (!(Test-Path $pdbTargetDirectory)) {
6565
New-Item $pdbTargetDirectory -ItemType directory
6666
}
6767
objcopy --only-keep-debug $dllFile.FullName "$pdbTargetDirectory/$($dllFile.Name).debug"
6868
strip --strip-debug $dllFile.FullName
6969
} else {
70-
Write-Output "Skip: $dllFile"
70+
Write-Host "Skip: $dllFile"
7171
}
7272
}
7373
Pop-Location

scripts/ci/Pack.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ if ($IsWindows) {
1717
New-Item -ItemType Directory -Force -Path $env:INNOSETUP_MESSAGE_FILES_DIR
1818
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/$InnoSetupCommit/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "$env:INNOSETUP_MESSAGE_FILES_DIR\ChineseSimplified.isl"
1919
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/$InnoSetupCommit/Files/Languages/Unofficial/ChineseTraditional.isl" -OutFile "$env:INNOSETUP_MESSAGE_FILES_DIR\ChineseTraditional.isl"
20-
ISCC $BuildDir/dist/installer/windows/setup.iss
20+
ISCC $BuildDir/dist/installer/windows/setup.iss | Write-Host
2121
if (! (Test-Path "${InstallerFileBase}.exe")) {
22-
Write-Error "Installer file was not created: ${InstallerFileBase}.exe"
23-
exit 1
22+
throw "Installer file was not created: ${InstallerFileBase}.exe"
2423
}
2524
Write-Output $(Resolve-Path "${InstallerFileBase}.exe")
2625
}

0 commit comments

Comments
 (0)