Skip to content

Commit 48689f4

Browse files
committed
Implemented CI workflow
1 parent 0d21364 commit 48689f4

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

.github/workflows/Code-Mods.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Code Mods
2+
on:
3+
push:
4+
branches: [ main ]
5+
jobs:
6+
build:
7+
name: ${{matrix.configuration}}
8+
runs-on: windows-2025-vs2026
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: 10.0.x
19+
- name: Build Code-Mods
20+
working-directory: ${{github.workspace}}
21+
run: ./Build.ps1 -Archive -Clean -Configuration ${{matrix.configuration}}
22+
- name: Upload Code-Mods Artifacts
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: Code-Mods-${{matrix.configuration}}
26+
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: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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.Directory]::CreateDirectory([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+
foreach ($project in $projects)
70+
{
71+
$projectDir = GetProjectProperty $project "ProjectDir"
72+
$projectName = GetProjectProperty $project "ProjectName"
73+
$binDir = [System.IO.Path]::Combine($projectDir, "bin")
74+
75+
if (![System.IO.Directory]::Exists($binDir))
76+
{
77+
Write-Host
78+
Write-Host ("***********************" + '*' * $binDir.Length) -ForegroundColor DarkRed
79+
Write-Host "* Cannot archive project binaries." -ForegroundColor DarkRed
80+
Write-Host "* Directory not found: ${binDir}" -ForegroundColor DarkRed
81+
Write-Host ("***********************" + '*' * $binDir.Length) -ForegroundColor DarkRed
82+
83+
exit -1
84+
}
85+
86+
$solutionArtifactsDir = [System.IO.Directory]::CreateDirectory([System.IO.Path]::Combine($artifactsDir.FullName, $solutionName))
87+
$projectArtifactPath = [System.IO.Path]::Combine($solutionArtifactsDir.FullName, "${projectName}.zip")
88+
89+
cd $binDir
90+
Compress-Archive -Force * $projectArtifactPath
91+
cd $work
92+
}
93+
}
94+
}

Tools/vswhere.exe

458 KB
Binary file not shown.

0 commit comments

Comments
 (0)