Skip to content

Commit

Permalink
feat(Actions): Add nightly build (#64)
Browse files Browse the repository at this point in the history
* feat(Actions): Add nightly build

* fix(Actions): ci workflow breaking because of rename
  • Loading branch information
Yimura authored Nov 16, 2023
1 parent 61dd656 commit 7990cda
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
path: build/HorseMenu-dev-*.dll
115 changes: 115 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 7990cda

Please sign in to comment.