Skip to content

Commit

Permalink
tweak(ci): update actions and build solution while running build script
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackFlash5 committed May 1, 2024
1 parent 0f0055b commit b658423
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,32 @@ jobs:
SolutionPath: saltychat\SaltyChat-RedM.sln

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NuGet.exe
uses: NuGet/setup-nuget@v1.0.5
uses: NuGet/setup-nuget@v2

- name: Restore NuGet packages
run: nuget restore $env:SolutionPath

- name: Setup MSBuild.exe
uses: microsoft/[email protected]

- name: Build solution
run: msbuild $env:SolutionPath /property:Configuration=Release
uses: microsoft/setup-msbuild@v2

- name: Prepare release
run: .\Build-Release.ps1
shell: powershell

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.6
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@v1.14.0
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: "release/*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
SolutionPath: saltychat\SaltyChat-RedM.sln

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NuGet.exe
uses: NuGet/setup-nuget@v1.0.5
uses: NuGet/setup-nuget@v2

- name: Restore NuGet packages
run: nuget restore $env:SolutionPath

- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v2

- name: Build solution
run: msbuild $env:SolutionPath
42 changes: 41 additions & 1 deletion Build-Release.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
if (Test-Path release)
# Find msbuild and use it later on
$msBuildPath = $null

if (Test-Path "C:\Program Files\Microsoft Visual Studio\2022\*\Msbuild\Current\Bin\MSBuild.exe")
{
$msBuildPath = "C:\Program Files\Microsoft Visual Studio\2022\*\Msbuild\Current\Bin\MSBuild.exe"
}
else
{
foreach($path in $env:Path.Split(";"))
{
if (Test-Path "$path\msbuild.exe")
{
$msBuildPath = "$path\msbuild.exe"

break
}
}

if ($msBuildPath -eq $null)
{
throw "Could not find msbuild"
}
}

# Cleanup/Create release directory
if (Test-Path release)
{
Remove-Item release\* -Recurse -Force
}
Expand All @@ -7,11 +33,23 @@ else
New-Item .\release -ItemType Directory | Out-Null
}

## Salty Chat ##

# Create build directory for Salty Chat
if ((Test-Path .\release\saltychat) -eq $false)
{
New-Item .\release\saltychat -ItemType Directory | Out-Null
}

# Build Salty Chat Solution
$buildOutput = (& $msBuildPath saltychat\SaltyChat-RedM.sln /property:Configuration=Release) -Join [System.Environment]::NewLine

if ($buildOutput -notmatch "Build succeeded.")
{
throw $buildOutput
}

# Copy all necessary items to the release directory
Copy-Item .\saltychat\NUI -Recurse -Destination .\release\saltychat
Copy-Item .\saltychat\config.json -Destination .\release\saltychat
Copy-Item .\saltychat\Newtonsoft.Json.dll -Destination .\release\saltychat
Expand All @@ -20,8 +58,10 @@ Copy-Item .\saltychat\SaltyClient\bin\Release\SaltyClient.net.pdb -Destination .
Copy-Item .\saltychat\SaltyServer\bin\Release\netstandard2.0\SaltyServer.net.dll -Destination .\release\saltychat
Copy-Item .\saltychat\SaltyServer\bin\Release\netstandard2.0\SaltyServer.net.pdb -Destination .\release\saltychat

# Adjust paths in fxmanifest
$scFxmanifest = Get-Content .\saltychat\fxmanifest.lua
$scFxmanifest = $scFxmanifest -replace 'Salty(Client|Server)\/bin\/Debug\/.*Salty(Client|Server).net.(dll|pdb)', 'Salty$2.net.$3'
$scFxmanifest | Set-Content .\release\saltychat\fxmanifest.lua

# Zip directory which will be used as release on GitHub
Compress-Archive .\release\saltychat\* -DestinationPath .\release\saltychat-redm.zip -CompressionLevel Optimal

0 comments on commit b658423

Please sign in to comment.