From 7990cda4f01f2610bb0f2ed680ba9093e309cc8b Mon Sep 17 00:00:00 2001 From: Andreas Maerten <24669514+Yimura@users.noreply.github.com> Date: Thu, 16 Nov 2023 20:57:56 +0100 Subject: [PATCH] feat(Actions): Add nightly build (#64) * feat(Actions): Add nightly build * fix(Actions): ci workflow breaking because of rename --- .github/workflows/ci.yml | 12 ++-- .github/workflows/nightly.yml | 115 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- 3 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1806a2a..1dcc1779 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,19 +21,19 @@ jobs: run: cmake -D CMAKE_BUILD_TYPE=Release -S. -Bbuild -G Ninja - name: Build 64bit release DLL - run: cmake --build ./build --config Release --target NewBase -- + run: cmake --build ./build --config Release --target HorseMenu -- - name: Check if DLL got built - run: if (-Not (Test-Path -path "build/NewBase.dll")) {throw 1} + run: if (-Not (Test-Path -path "build/HorseMenu.dll")) {throw 1} - - name: Rename DLL to NewBase-dev-{GITHUB_SHA}.dll + - name: Rename DLL to HorseMenu-dev-{GITHUB_SHA}.dll run: | - del NewBase-dev-*.dll - ren NewBase.dll NewBase-dev-${{github.sha}}.dll + del HorseMenu-dev-*.dll + ren HorseMenu.dll HorseMenu-dev-${{github.sha}}.dll working-directory: build/ - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: binary - path: build/NewBase-dev-*.dll \ No newline at end of file + path: build/HorseMenu-dev-*.dll \ No newline at end of file diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000..696bdf4b --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,115 @@ +name: Nightly Build + +on: + schedule: + # cronjob that triggers every day at 2PM UTC + - cron: '0 14 * * *' + workflow_dispatch: + +jobs: + build_nightly: + runs-on: [self-hosted, Windows] + name: Build Nightly + outputs: + full_sha: ${{ steps.var.outputs.full_sha }} + short_sha: ${{ steps.var.outputs.short_sha }} + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Check CMake version + run: cmake --version + + - name: Setup MSVC environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - name: Generate CMake project + run: cmake -D CMAKE_BUILD_TYPE=Release -S. -Bbuild -G Ninja + + - name: Build 64bit release DLL + run: cmake --build ./build --config Release --target HorseMenu -- + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: binary + path: build/HorseMenu.dll + + - name: Generate Build Info + id: var + run: | + echo "full_sha=$(git rev-parse HEAD)" >> $env:GITHUB_OUTPUT + echo "short_sha=$(git rev-parse --short HEAD)" >> $env:GITHUB_OUTPUT + + check_date: + runs-on: ubuntu-latest + name: Check latest commit + needs: build_nightly + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v3 + + - id: should_run + continue-on-error: true + name: Check if latest commit date is within the previous 24 hours + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT + + create_release: + runs-on: ubuntu-latest + name: Create Release + needs: [ check_date, build_nightly ] + if: ${{ needs.check_date.outputs.should_run != 'false' }} + steps: + - uses: actions/checkout@v3 + - name: Download Artifact + uses: actions/download-artifact@v3 + with: + name: binary + + - name: Echo build sha256 + id: build_sha + run: | + sha256sum HorseMenu.dll > sha256.checksum + echo "build_sha=$(cat sha256.checksum)" >> $GITHUB_OUTPUT + cat sha256.checksum + + - name: Run latest-tag + uses: EndBug/latest-tag@84c87607fcb948bcef069c9a27445e653113979f + with: + ref: nightly + + - name: Nightly Release + uses: softprops/action-gh-release@v1 + with: + name: Nightly [${{ needs.build_nightly.outputs.short_sha }}] + tag_name: nightly + body: | + **This release has been built by Github Actions** + [Link to build](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + Build SHA256: + ``` + ${{ steps.build_sha.outputs.build_sha }} + ``` + To verify the build SHA256 during the action, click the build link, go-to "Create Release", open the Echo build sha256 step and read the sha256. + + You can download the build artifacts, generate a SHA256 checksum and compare it with the below binary. + Build artifacts ARE NOT automatically the same as release assets since release assets can be modified afterwards. + + These are nightly builds of HorseMenu, they are provided for testing purposes only: + - Test if your build environment produces a broken HorseMenu.dll + - Test if source code is out of date and no longer compatible with the current version of GTA V + + If you wish to use this menu as-is you are on your own, no warranty is provided. + + Full Commit Hash: + ``` + ${{ needs.build_nightly.outputs.full_sha }} + ``` + files: | + HorseMenu.dll \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1786a3e2..b05648dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.x) -project(NewBase VERSION 0.0.1 DESCRIPTION "A new base using new C++ features optimised for speed and ease of use") +project(HorseMenu VERSION 0.0.1 DESCRIPTION "A new base using new C++ features optimised for speed and ease of use") # libs include(cmake/vulkan.cmake)