Skip to content

Commit ac5fb65

Browse files
committed
Implemented CI workflow
1 parent 0d21364 commit ac5fb65

4 files changed

Lines changed: 127 additions & 0 deletions

File tree

.github/workflows/Code-Mods.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Code Mods
2+
on:
3+
push:
4+
branches: [ main ]
5+
jobs:
6+
build:
7+
name: ${{matrix.configuration}}
8+
runs-on: windows-2022
9+
strategy:
10+
matrix:
11+
configuration: [ Debug, Release ]
12+
steps:
13+
- name: Clone Code-Mods
14+
uses: actions/checkout@v6
15+
- name: Install .NET SDKs
16+
uses: actions/setup-dotnet@v5
17+
with:
18+
dotnet-version: |
19+
4.7.2
20+
10.0.x
21+
- name: Build Code-Mods
22+
working-directory: ${{github.workspace}}
23+
run: ./Build.ps1 -Archive -Clean -Configuration ${{matrix.configuration}}
24+
- name: Upload Code-Mods Artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: Code-Mods-${{matrix.configuration}}
28+
path: ${{github.workspace}}/Artifacts/*/*.zip

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,6 @@ MigrationBackup/
347347

348348
# Ionide (cross platform F# VS Code tools) working folder
349349
.ionide/
350+
351+
# Build artifacts
352+
Artifacts/

Build.ps1

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
param
2+
(
3+
[Switch]$Archive,
4+
[String]$Configuration = "Release",
5+
[Switch]$Clean,
6+
[Switch]$Help
7+
)
8+
9+
$work = $pwd
10+
$artifactsDir = [System.IO.Path]::Combine($work, "Artifacts")
11+
12+
if ($Help)
13+
{
14+
Write-Host "Code Mods Build Script"
15+
Write-Host
16+
Write-Host "Parameters:"
17+
Write-Host "-Archive - archives the build artifacts."
18+
Write-Host "-Configuration [name] - build with a specific configuration."
19+
Write-Host "-Clean - clean the solutions before building."
20+
Write-Host "-Help - display help."
21+
exit
22+
}
23+
24+
$vs = ./Tools/vswhere.exe -nologo -latest -prerelease -property installationPath
25+
$vsCommonTools = [System.IO.Path]::Combine($vs, "Common7", "Tools")
26+
27+
pushd $vsCommonTools
28+
cmd /c "VsDevCmd.bat > nul 2> nul &set" |
29+
foreach {
30+
if ($_ -match "=") {
31+
$v = $_.split("=", 2)
32+
Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
33+
}
34+
}
35+
popd
36+
37+
function GetProjectProperty([String]$in_projectPath, [String]$in_propertyName)
38+
{
39+
return & msbuild /NoLogo /p:Configuration="${Configuration}" -getProperty:"${in_propertyName}" "${in_projectPath}"
40+
}
41+
42+
foreach ($solutionPath in [System.IO.Directory]::EnumerateFiles("${work}/Games/", "*.sln", [System.IO.SearchOption]::AllDirectories))
43+
{
44+
$solutionDir = Split-Path $solutionPath
45+
$solutionName = [System.IO.Path]::GetFileNameWithoutExtension($solutionPath)
46+
47+
$target = "Build"
48+
49+
if ($Clean)
50+
{
51+
$target = "Clean;" + $target
52+
}
53+
54+
Write-Host
55+
Write-Host ("**************" + '*' * $solutionPath.Length) -ForegroundColor DarkGreen
56+
Write-Host "* Solution: ${solutionPath} *" -ForegroundColor DarkGreen
57+
Write-Host ("**************" + '*' * $solutionPath.Length) -ForegroundColor DarkGreen
58+
59+
& msbuild /NoLogo /v:m /t:"${target}" /Restore /p:RestorePackagesConfig=true /p:Configuration="${Configuration}" "${solutionPath}"
60+
61+
if ($Archive)
62+
{
63+
$projects = dotnet sln "${solutionPath}" list |
64+
Select-Object -Skip 2 |
65+
ForEach-Object {
66+
Join-Path $solutionDir $_.Trim()
67+
}
68+
69+
[System.IO.Directory]::CreateDirectory($artifactsDir)
70+
71+
foreach ($project in $projects)
72+
{
73+
$projectDir = GetProjectProperty $project "ProjectDir"
74+
$projectName = GetProjectProperty $project "ProjectName"
75+
$binDir = [System.IO.Path]::Combine($projectDir, "bin")
76+
77+
if (![System.IO.Directory]::Exists($binDir))
78+
{
79+
Write-Host
80+
Write-Host ("***********************" + '*' * $binDir.Length) -ForegroundColor DarkRed
81+
Write-Host "* Cannot archive project binaries." -ForegroundColor DarkRed
82+
Write-Host "* Directory not found: ${binDir}" -ForegroundColor DarkRed
83+
Write-Host ("***********************" + '*' * $binDir.Length) -ForegroundColor DarkRed
84+
85+
exit -1
86+
}
87+
88+
$solutionArtifactsDir = [System.IO.Directory]::CreateDirectory([System.IO.Path]::Combine($artifactsDir, $solutionName))
89+
$projectArtifactPath = [System.IO.Path]::Combine($solutionArtifactsDir.FullName, "${projectName}.zip")
90+
91+
cd $binDir
92+
Compress-Archive -Force * $projectArtifactPath
93+
cd $work
94+
}
95+
}
96+
}

Tools/vswhere.exe

458 KB
Binary file not shown.

0 commit comments

Comments
 (0)