Skip to content

msbuild.yml: Improvements #583

msbuild.yml: Improvements

msbuild.yml: Improvements #583

Workflow file for this run

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 $folderName)) {
mkdir ".\dist\$folderName"
}
$destFile = Join-Path ".\dist\$folderName" $file.Name
Move-Item $file.FullName "$destFile" -Force
$hash = Get-FileHash -Path "$destFile" -Algorithm SHA512 | Format-List
$hash | Out-File -Append -Encoding utf8 -FilePath ".\dist\hashes.txt"
# Add-Content -Path $hashFilePath -Value $hashString
}
# Copy the dinput8.dll file to each subfolder
$sourceFile = ".\dinput8.dll"
$subFolders = Get-ChildItem $rootPath -Directory
foreach ($folder in $subFolders) {
$destFile = Join-Path $folder.FullName "dinput8.dll"
Copy-Item $sourceFile $destFile -Force
}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.zip_name }}
path: |
${{ env.BUILD_CONFIGURATION }}/dist/*
${{ env.BUILD_CONFIGURATION }}/*.ini
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
${{ env.BUILD_CONFIGURATION }}/*.ini
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 -Encoding utf8 -FilePath hash.md
Get-Content hash.md
$compress = @{
Path = "${{ env.BUILD_CONFIGURATION }}\dist\*", ".\${{ env.BUILD_CONFIGURATION }}\*.pdb", ".\${{ env.BUILD_CONFIGURATION }}\*.ini"
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