Skip to content

Commit 7814121

Browse files
committed
GitHub Actions initial
1 parent a8b05e3 commit 7814121

File tree

3 files changed

+187
-3
lines changed

3 files changed

+187
-3
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build plugin
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
name: RedLua
11+
runs-on: windows-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Get previous tag
19+
id: prevtag
20+
uses: WyriHaximus/github-action-get-previous-tag@v1
21+
with:
22+
fallback: '0.1'
23+
24+
- name: Checkout LuaJIT
25+
uses: actions/checkout@v3
26+
with:
27+
path: .\src\thirdparty\LuaJIT
28+
repository: LuaJIT/LuaJIT
29+
fetch-depth: 0
30+
31+
- name: Download ScriptHookSDK
32+
shell: pwsh
33+
run: .\misc\ScriptHook.ps1
34+
35+
- name: Detect MSVC
36+
uses: ilammy/msvc-dev-cmd@v1
37+
with:
38+
arch: x86_64
39+
40+
- name: Build plugin
41+
run: .\build.bat
42+
43+
- name: Build release archive
44+
run: |
45+
mkdir .\objs\output\RedLua\
46+
curl.exe -o.\objs\output\RedLua\natives.json https://raw.githubusercontent.com/alloc8or/rdr3-nativedb-data/master/natives.json
47+
7z.exe a -tzip .\objs\out.zip .\objs\output\*.* -r
48+
49+
- name: Create release
50+
id: release
51+
uses: actions/create-release@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
tag_name: ${{ github.ref }}
56+
release_name: Pre-release ${{ github.ref_name }}
57+
body: |
58+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prevtag.outputs.tag }}...${{ github.ref_name }}
59+
draft: false
60+
prerelease: true
61+
62+
- name: Upload assets
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ steps.release.outputs.upload_url }}
68+
asset_path: .\objs\out.zip
69+
asset_name: RedLua-${{ github.ref_name }}.zip
70+
asset_content_type: application/zip

build.bat

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,28 @@ IF NOT "%VSCMD_ARG_TGT_ARCH%"=="x64" (
55
)
66
setlocal enableextensions enabledelayedexpansion
77
SET RL_LUAJIT_SOURCE_DIR=.\src\thirdparty\luajit\src
8+
IF NOT EXIST "%RL_LUAJIT_SOURCE_DIR%\lua51.lib" (
9+
PUSHD %RL_LUAJIT_SOURCE_DIR%
10+
CALL .\msvcbuild.bat
11+
IF NOT "!ERRORLEVEL!"=="0" (
12+
ECHO Failed to compile LuaJIT
13+
EXIT /b 1
14+
)
15+
POPD
16+
)
817
SET RL_SCRIPTHOOK_SDK_DIR=.\src\thirdparty\ScriptHook
9-
SET RL_OUT_PATH="D:\SteamLibrary\steamapps\common\Red Dead Redemption 2\RedLua.asi"
18+
SET RL_OUT_PATH="D:\SteamLibrary\steamapps\common\Red Dead Redemption 2"
19+
MKDIR ".\objs\" 2> NUL
20+
IF NOT EXIST !RL_OUT_PATH! (
21+
SET RL_OUT_PATH=".\objs\output"
22+
MKDIR !RL_OUT_PATH! 2> NUL
23+
)
24+
IF NOT EXIST "!RL_OUT_PATH!\lua51.dll" (
25+
COPY %RL_LUAJIT_SOURCE_DIR%\lua51.dll %RL_OUT_PATH% 2> NUL
26+
)
1027
SET RL_CFLAGS=/DELPP_NO_DEFAULT_LOG_FILE /DELPP_DISABLE_LOG_FILE_FROM_ARG /W2 ^
11-
/Isrc\ /EHsc /MP /MT /DLL /Foobjs\ /Fe%RL_OUT_PATH%
12-
SET RL_LDFLAGS=/incremental /libpath:"%RL_LUAJIT_SOURCE_DIR%" /libpath:"%RL_SCRIPTHOOK_SDK_DIR%\lib" /dll
28+
/Isrc\ /EHsc /MP /MT /DLL /Foobjs\ /Fe!RL_OUT_PATH!\RedLua.asi
29+
SET RL_LDFLAGS=/INCREMENTAL /LIBPATH:"%RL_LUAJIT_SOURCE_DIR%" /LIBPATH:"%RL_SCRIPTHOOK_SDK_DIR%\lib" /dll
1330
SET RL_LIBS=ScriptHookRDR2.lib user32.lib shell32.lib lua51.lib
1431
SET RL_SOURCES=src\*.cpp src\thirdparty\*.cpp src\menus\*.cpp
1532
CL %RL_CFLAGS% %RL_SOURCES% /link %RL_LDFLAGS% %RL_LIBS%

misc/ScriptHook.ps1

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
$SCR_DIR = $(Split-Path $MyInvocation.MyCommand.Path -Parent)
2+
$SHOOK_DIR = "$SCR_DIR/../src/thirdparty/ScriptHook"
3+
$DOMAIN = "http://www.dev-c.com"
4+
$LINK = "/rdr2/scripthookrdr2/"
5+
$FILES = @(
6+
"inc/", "lib/",
7+
"inc/enums.h", "inc/main.h", "inc/nativeCaller.h", "inc/natives.h",
8+
"inc/types.h", "lib/ScriptHookRDR2.lib", "readme.txt"
9+
)
10+
$PATCHES = @{
11+
"inc/main.h" = @(
12+
,@(
13+
"VER_1_0_1207_69_RGS,`r`n`r`n`tVER_SIZE",
14+
("`VER_1_0_1207_69_RGS,`r`n" +
15+
"`r`n`t//Added by patcher`r`n" +
16+
"`tVER_1_0_1207_73_RGS,`r`n" +
17+
"`tVER_1_0_1207_77_RGS,`r`n" +
18+
"`tVER_1_0_1207_80_RGS,`r`n" +
19+
"`tVER_1_0_1232_13_RGS,`r`n" +
20+
"`tVER_1_0_1232_17_RGS,`r`n" +
21+
"`tVER_1_0_1311_12_RGS,`r`n" +
22+
"`tVER_1_0_1436_25_RGS,`r`n" +
23+
"`tVER_1_0_1436_31_RGS,`r`n" +
24+
"`r`n`tVER_SIZE")
25+
)
26+
)
27+
}
28+
29+
if(Test-Path -PathType Container $SHOOK_DIR) {
30+
$corrupted = $false
31+
32+
Foreach($item in $FILES) {
33+
if(!(Test-Path "$SHOOK_DIR/$item")) {
34+
$corrupted = $true;
35+
break
36+
}
37+
}
38+
39+
if($corrupted) {
40+
$title = "Corrupted ScriptHookRDR2 installation"
41+
$text = "Looks like you have a broken ScriptHookRDR2, do you want to redownload it?"
42+
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
43+
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList "&Yes", "ScriptHookRDR2 will be redownloaded"))
44+
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList "&No", "This script will close"))
45+
switch($Host.UI.PromptForChoice($title, $text, $choices, 1)) {
46+
0 {
47+
Remove-Item -Recurse -Force $SHOOK_DIR
48+
}
49+
1 {
50+
Write-Host "Operation cancelled"
51+
Exit 0
52+
}
53+
}
54+
} else {
55+
Exit 0
56+
}
57+
} else {
58+
New-Item -ItemType Directory -Path $SHOOK_DIR
59+
}
60+
61+
62+
$HEADERS = @{
63+
"Referer" = ($DOMAIN + $LINK);
64+
"User-Agent" = "RL/1.0"
65+
}
66+
67+
Foreach($elem in (Invoke-WebRequest -URI ($DOMAIN + $LINK)).Links.Href) {
68+
if($elem.IndexOf("ScriptHookRDR2_SDK") -ige 0) {
69+
$outFile = "$SCR_DIR/temp.zip";
70+
Invoke-WebRequest -Uri ($DOMAIN + $elem) -OutFile $outFile -Headers $HEADERS
71+
Add-Type -Assembly System.IO.Compression.FileSystem
72+
$zip = [IO.Compression.ZipFile]::OpenRead($outFile)
73+
Foreach($ent in $zip.Entries) {
74+
$fileName = $ent.FullName
75+
if($FILES.Contains($fileName)) {
76+
if($fileName.Substring($fileName.Length - 1) -eq '/') {
77+
New-Item -ItemType Directory -Path "$SHOOK_DIR\$filename"
78+
Continue
79+
}
80+
[IO.Compression.ZipFileExtensions]::ExtractToFile($ent, "$SHOOK_DIR\$fileName", $true)
81+
}
82+
}
83+
$zip.Dispose()
84+
Foreach($fpatches in $PATCHES.GetEnumerator()) {
85+
$fileName = "$SHOOK_DIR/$($fpatches.Name)"
86+
$content = (Get-Content $fileName -Raw)
87+
Foreach($patch in $fpatches.Value) {
88+
$content = $content -replace $patch[0], $patch[1]
89+
}
90+
$content | Set-Content $fileName -Force
91+
}
92+
Remove-Item -Path $outFile
93+
Exit 0
94+
}
95+
}
96+
97+
Write-Error "SDK link not found"

0 commit comments

Comments
 (0)