forked from scripthookvdotnet/scripthookvdotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (91 loc) · 3.82 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Build
on:
workflow_call:
inputs:
build-version:
required: false
type: string
permissions:
contents: read
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup MSBuild.exe
uses: microsoft/[email protected]
with:
msbuild-architecture: x64
vs-version: 17.7.6
- name: Add VSTest.Console to PATH
working-directory: ${{env.SOLUTION_FILE_PATH}}
run: |
$vstest_parent_path = (.github/workflows/find-vstest-path.ps1)
if ($vstest_parent_path -eq "")
{
throw "Failed to find the parent path of VSTest.Console."
}
echo $vstest_parent_path
Add-Content $env:GITHUB_PATH $vstest_parent_path
- name: Install ScriptHookV SDK
working-directory: ${{env.SOLUTION_FILE_PATH}}
run: ./tools/install_sdk.ps1
- name: Define SHVDN version
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
$CustomBuildVersionInput = "${{inputs.build-version}}"
if ($CustomBuildVersionInput -ne "")
{
$env:SHVDN_VERSION = echo "$($CustomBuildVersionInput)"
}
else
{
$VerInputAsFallback = ""
$currentRefIsVersionTag = $env:GITHUB_REF -match '^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)'
if ($currentRefIsVersionTag) {
$VerInputAsFallback = $matches[1]
}
if ($VerInputAsFallback -eq "")
{
git fetch --unshallow 2>&1 | Out-Null
$env:SHVDN_VERSION = echo "$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" refs/tags |% { $_.Substring(1) })"
}
else
{
$env:SHVDN_VERSION = "$($VerInputAsFallback)"
}
}
echo "Version: v$($env:SHVDN_VERSION)"
echo "SHVDN_VERSION=$($env:SHVDN_VERSION)" >> $env:GITHUB_ENV
- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
- name: Build solution and put misc files for packing
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild /m /p:configuration=Release /p:platform=x64 ScriptHookVDotNet.sln `
&& del bin\Release\ScriptHookVDotNet*.metagen
- name: Run tests
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
# Set verbosity to `minimal` so only failed tests would print (set to `normal` by default in VSTest.Console)
vstest.console "source\scripting_v3_tests\bin\x64\Release\net48\ScriptHookVDotNet_APIv3_Tests.dll" "/logger:console;verbosity=minimal"
- name: Put misc files for packing
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
$robocopy_process = Start-Process "robocopy" -ArgumentList ". bin\Release README.md ScriptHookVDotNet.ini LICENSE.txt COPYRIGHT.md THIRD-PARTY-NOTICES.md" -PassThru -Wait
if ($robocopy_process.ExitCode -ne 1) { exit 1 }
cd bin\Release `
&& Get-ChildItem -File -Filter *.md | Rename-Item -NewName { $_.Name -replace '.md','.txt' }
mkdir "Docs","Licenses"
$shvdn_xml_docs_arg = (Get-ChildItem -File -Path "./" | Where-Object { $_.Name -match "^ScriptHookVDotNet[0-9]{1,2}.xml`$" } | ForEach-Object { $_.Name }) -join " "
$robocopy_process = Start-Process "robocopy" -ArgumentList ". Docs ${shvdn_xml_docs_arg} /move" -PassThru -Wait
if ($robocopy_process.ExitCode -ne 1) { exit 1 }
$robocopy_process = Start-Process "robocopy" -ArgumentList ". Licenses LICENSE.txt COPYRIGHT.txt THIRD-PARTY-NOTICES.txt /move" -PassThru -Wait
if ($robocopy_process.ExitCode -ne 1) { exit 1 }
cd ..\..\
- name: Upload artifact
uses: actions/[email protected]
with:
name: ScriptHookVDotNet
path: bin/Release/*