-
-
Notifications
You must be signed in to change notification settings - Fork 6
123 lines (111 loc) · 4.33 KB
/
msbuild.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: MSBuild
on:
push:
paths-ignore:
- '**/*.md'
- '**/*.txt'
pull_request:
paths-ignore:
- '**/*.md'
- '**/*.txt'
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
env:
BUILD_CONFIGURATION: Release
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout main repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup environment variables
run: |
$cmdOutput = Split-Path -Path $pwd -Leaf
$_ver = "1.0.$(git rev-list HEAD --count)-$(git rev-parse --short=8 HEAD)"
echo "commit_ver=$_ver" >> "$Env:GITHUB_ENV"
echo "zip_name=$cmdOutput-$_ver" >> "$Env:GITHUB_ENV"
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@main
- name: Build
run: msbuild /m /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=x64 Windows-Game-Patches.sln
- name: Add ASI Loader to archive
working-directory: ${{ env.BUILD_CONFIGURATION }}
run: |
$hook_alias="Ultimate-ASI-Loader_x64.zip"
curl -fLO "https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/latest/download/$hook_alias"
Expand-Archive -Path "$hook_alias" -DestinationPath "."
$rootPath = "."
$asiFiles = Get-ChildItem "$rootPath" -Filter "*.asi" -File
foreach ($file in $asiFiles) {
$folderName = Join-Path $rootPath ($file.BaseName)
if (-not (Test-Path "dist\$folderName")) {
mkdir "dist\$folderName"
}
$destFile = Join-Path "dist\$folderName" $file.Name
Move-Item $file.FullName "$destFile" -Force
# Copy additional files
$otherFiles = Get-ChildItem "$rootPath" -Filter ($file.BaseName + "_*.*") -File
foreach ($otherFile in $otherFiles) {
# Strip game name
$destOtherFile = Join-Path "dist\$folderName" $otherFile.Name.Replace(($file.BaseName + "_"), "")
if ($otherFile.Extension -ne ".dll") {
# Move the additional file
Move-Item $otherFile.FullName "$destOtherFile" -Force
} else {
# Copy and rename dinput8 and remove the dummy file
Copy-Item "dinput8.dll" "$destOtherFile" -Force
Remove-Item $otherFile.FullName
}
}
$hash = Get-FileHash -Path "$destFile" -Algorithm SHA512 | Format-List
$hash | Out-File -Append -FilePath "dist\hashes.txt"
# Add-Content -Path $hashFilePath -Value $hashString
}
# Remove downloaded dinput8.dll
Remove-Item "dinput8.dll"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.zip_name }}
path: |
${{ env.BUILD_CONFIGURATION }}/dist/*
if-no-files-found: error
- name: Upload Artifact (pdb)
uses: actions/upload-artifact@v3
with:
name: ${{ env.zip_name }}-pdb
path: |
${{ env.BUILD_CONFIGURATION }}/dist/**/*.asi
${{ env.BUILD_CONFIGURATION }}/*.pdb
if-no-files-found: error
- name: Create Release
if: |
github.event_name == 'workflow_dispatch' &&
github.repository == 'illusion0001/Windows-Game-Patches'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$hashMarkdown = @'
{0}
<details>
<summary>ASI Plugin Hashes (Click to Expand)</summary>
```yaml
{1}
```
</details>
'@ -f (Get-Content ".github\README.md" | Out-String), (Get-Content "${{ env.BUILD_CONFIGURATION }}\dist\hashes.txt" | Out-String)
$hashMarkdown | Out-File -FilePath hash.md
Get-Content hash.md
$compress = @{
Path = "${{ env.BUILD_CONFIGURATION }}\dist\*", "${{ env.BUILD_CONFIGURATION }}\*.pdb"
DestinationPath = "${{ env.zip_name }}.zip"
}
Compress-Archive @compress
gh release create ${{ env.commit_ver }} ${{ env.ZIP_NAME }}.zip --target ${{ GITHUB.SHA }} -t "${{ env.commit_ver }}" -F hash.md # --draft --prerelease