From b9915631900e70ffddcc6db3b237afc4757b6222 Mon Sep 17 00:00:00 2001 From: Notiooo Date: Mon, 19 Feb 2024 19:05:34 +0100 Subject: [PATCH] Add github workflow that provides build when release --- .github/workflows/build_on_release.yml | 55 ++++++++++++++++++++++++++ MakeFarm/src/Renderer3D/Renderer3D.cpp | 4 -- MakeFarm/src/Utils/Mouse.cpp | 2 + 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build_on_release.yml diff --git a/.github/workflows/build_on_release.yml b/.github/workflows/build_on_release.yml new file mode 100644 index 0000000..6309f46 --- /dev/null +++ b/.github/workflows/build_on_release.yml @@ -0,0 +1,55 @@ +name: C++ Build and Package + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + env: + TAG_NAME: ${{ github.ref_name }} + + steps: + - uses: actions/checkout@v3 + + - name: Build (Release) + run: | + cmake -S ${{github.workspace}}/MakeFarm -B ${{github.workspace}}/build-release -DCMAKE_BUILD_TYPE=Release + cmake --build ${{github.workspace}}/build-release --config Release --target MakeFarmApp + + - name: Package (Release) + run: | + Compress-Archive -Path "${{github.workspace}}/build-release/src/Release/*" -DestinationPath "${{github.workspace}}/build-release/src/makefarm_release_windows_build_${{ env.TAG_NAME }}.zip" + + - name: Build (Debug) + run: | + cmake -S ${{github.workspace}}/MakeFarm -B ${{github.workspace}}/build-debug -DCMAKE_BUILD_TYPE=Debug + cmake --build ${{github.workspace}}/build-debug --config Debug --target MakeFarmApp + + - name: Package (Debug) + run: | + $excludeExtensions = @('.pdb', '.ilk', '.cmake') + $excludeFiles = @('MakeFarmSrc.lib') + $excludeFolders = @('custom_includes', 'CMakeFiles') + + $filesToCompress = Get-ChildItem "${{github.workspace}}/build-debug/src/Debug/*" -Recurse | Where-Object { + $excludeExtensions -notcontains $_.Extension -and + $excludeFiles -notcontains $_.Name -and + $excludeFolders -notcontains $_.Directory.Name + } + if ($filesToCompress.Count -gt 0) { + Compress-Archive -Path $filesToCompress.FullName -DestinationPath "${{github.workspace}}/build-debug/src/makefarm_debug_windows_build_${{ env.TAG_NAME }}.zip" + } else { + Write-Host "No files match the criteria for compression." + } + + - name: List files before upload release assets + run: Get-ChildItem + + - name: Upload Release Assets + uses: AButler/upload-release-assets@v3.0 + with: + files: "./build-release/src/makefarm_release_windows_build_*.zip;./build-debug/src/makefarm_debug_windows_build_*.zip" + repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/MakeFarm/src/Renderer3D/Renderer3D.cpp b/MakeFarm/src/Renderer3D/Renderer3D.cpp index 3cad332..b46c489 100644 --- a/MakeFarm/src/Renderer3D/Renderer3D.cpp +++ b/MakeFarm/src/Renderer3D/Renderer3D.cpp @@ -40,11 +40,9 @@ void Renderer3D::draw(const VertexArray& va, const IndexBuffer& ib, const sf::Sh ib.bind(); GLCall(glDrawElements(toOpenGL(drawMode), ib.size(), GL_UNSIGNED_INT, nullptr)); -#ifdef _DEBUG sf::Shader::bind(nullptr); va.unbind(); ib.unbind(); -#endif } void Renderer3D::draw(const VertexArray& va, const sf::Shader& shader, int number, @@ -54,10 +52,8 @@ void Renderer3D::draw(const VertexArray& va, const sf::Shader& shader, int numbe va.bind(); GLCall(glDrawArrays(toOpenGL(drawMode), 0, number)); -#ifdef _DEBUG sf::Shader::bind(nullptr); va.unbind(); -#endif } unsigned Renderer3D::toOpenGL(const Renderer3D::DrawMode& drawMode) const diff --git a/MakeFarm/src/Utils/Mouse.cpp b/MakeFarm/src/Utils/Mouse.cpp index 87cbaf7..4588e26 100644 --- a/MakeFarm/src/Utils/Mouse.cpp +++ b/MakeFarm/src/Utils/Mouse.cpp @@ -58,6 +58,8 @@ void Mouse::handleFirstPersonBehaviour(const sf::Event& event, sf::RenderWindow& { Mouse::lockMouseAtCenter(gameWindow); } +#else + Mouse::lockMouseAtCenter(gameWindow); #endif } }