diff --git a/.gitea/workflows/windows.yaml b/.gitea/workflows/windows.yaml new file mode 100644 index 0000000..fe69ef2 --- /dev/null +++ b/.gitea/workflows/windows.yaml @@ -0,0 +1,26 @@ +name: Windows CI +on: [push] + +jobs: + build: + runs-on: [windows11] + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run a one-line script + run: | + resources/build.ps1 build + resources/build.ps1 deploy + - name: Generate Changelog + run: | + current_tag=$(git describe --tags --abbrev=0) + previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1)) + echo "Commits from ${previous_tag} to ${current_tag}:" + git log ${previous_tag}..${current_tag} --reverse --pretty=format:"%B" | nl -w2 -s". " + git log ${previous_tag}..${current_tag} --reverse --pretty=format:"%B" | nl -w2 -s". " > ${{ github.workspace }}-CHANGELOG.txt + - name: Upload Gitea Release + uses: akkuman/gitea-release-action@v1 + with: + body_path: ${{ github.workspace }}-CHANGELOG.txt + files: |- + build/SmartLockerTools.zip \ No newline at end of file diff --git a/resources/build.ps1 b/resources/build.ps1 new file mode 100644 index 0000000..090335d --- /dev/null +++ b/resources/build.ps1 @@ -0,0 +1,95 @@ +param($type) + +$MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Community\Common7\Tools\Launch-VsDevShell.ps1' +if (!(Test-Path $MsvcScript)) { $MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Professional\Common7\Tools\Launch-VsDevShell.ps1' } +. $MsvcScript -SkipAutomaticLocation -Arch amd64 + +$qtHome = "D:\Qt\6.7.3\msvc2019_64" +$openSSLRoot = "D:\Qt\Tools\OpenSSLv3\Win_x64" +$boostRoot = "E:\Projects\Libraries\boost_1_86_0_msvc2022_64bit" +$ffmpegRoot = "E:\Projects\Libraries\ffmpeg-7.0.2-full_build-shared" + +$projectPath = Get-Location +$buildPath = Join-Path -Path $projectPath -ChildPath "build" +$deployPath = Join-Path -Path $buildPath -ChildPath "SmartLockerTools" +$zipFilePath = Join-Path -Path $buildPath -ChildPath "SmartLockerTools.zip" + +function Build() { + if (!(Test-Path $buildPath\CMakeCache.txt)) { + cmake.exe -G Ninja -S . -B build ` + -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_PREFIX_PATH=$qtHome ` + -DQT_DIR="$qtHome\lib\cmake\Qt6" ` + -DQt6_DIR="$qtHome\lib\cmake\Qt6" ` + -DQt6CoreTools_DIR="$qtHome\lib\cmake\Qt6CoreTools" ` + -DQt6QmlTools_DIR="$qtHome\lib\cmake\Qt6QmlTools" + } + + cmake.exe --build $buildPath --target all +} + +function Deploy() { + if (Test-Path $deployPath) { + Remove-Item $deployPath -Recurse -Force + } + New-Item $deployPath -ItemType Directory + Copy-Item $buildPath\Analyser\Analyser.exe $deployPath\Analyser.exe + Copy-Item $buildPath\OtaUpdate\SmartLockerUpdater.exe $deployPath\SmartLockerUpdater.exe + + $executables = "Analyser.exe", "SmartLockerUpdater.exe" + foreach ($executable in $executables) { + & $qtHome\bin\windeployqt.exe $deployPath\$executable --qmldir=$qtHome\qml + } + + $modules = "QmlCore" + foreach ($module in $modules) { + Copy-Item -Path $qtHome\bin\Qt6$module.dll -Destination $deployPath + } + + New-Item $deployPath\qml\QtCore -ItemType Directory + $plugins = "qtqmlcoreplugin.dll","qmldir","plugins.qmltypes" + foreach ($plugin in $plugins) { + Copy-Item -Path $QtHome\qml\QtCore\$plugin -Destination $deployPath\qml\QtCore + } + + Copy-Item $openSSLRoot\bin\libssl-3-x64.dll $deployPath + Copy-Item $openSSLRoot\bin\libcrypto-3-x64.dll $deployPath + + $boosts = "thread", "filesystem", "log" + foreach ($boost in $boosts) { + Copy-Item -Path $boostRoot\lib\boost_$boost-vc143-mt-x64-1_86.dll -Destination $deployPath + } + + $ffmpegs = "avcodec-61", "avdevice-61", "avfilter-10", "avformat-61", "avutil-59", "postproc-58", "swresample-5", "swscale-8" + foreach ($ffmpeg in $ffmpegs) { + Copy-Item -Path $ffmpegRoot\bin\$ffmpeg.dll -Destination $deployPath + } + + Compress-Archive -Path $deployPath -DestinationPath $zipFilePath -Force +} + +function Clean() { + if (Test-Path $buildPath) { + Remove-Item $buildPath -Recurse -Force + } +} + + + +switch ($type) { + "build" { + Build + } + "deploy" { + Deploy + } + "clean" { + Clean + } + "installer" { + Installer + } + "update" { + UpdateServer + } +} \ No newline at end of file