-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalbuilder.ps1
More file actions
134 lines (111 loc) · 6.51 KB
/
localbuilder.ps1
File metadata and controls
134 lines (111 loc) · 6.51 KB
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
124
125
126
127
128
129
130
131
132
133
134
using module ./scripts/core/core.psm1
[cmdletbinding()]
param (
[switch]$Automator,
[switch]$build_dotnet_lib,
[switch]$Build,
[switch]$PsGal,
[switch]$Nuget,
[switch]$ChocoNuSpec,
[switch]$ChocoPackage,
[switch]$ChocoPackageWindows,
[switch]$Phwriter,
[switch]$pester,
[switch]$cleanup
)
# Import Module config
#---CONFIG----------------------------
$ModuleConfig = (Get-Content -Path ./build_config.json | ConvertFrom-Json).PSModule
$ModuleName = $ModuleConfig.moduleName
#---CONFIG----------------------------
#---UI ELEMENTS Shortened-------------
$interLogger = $global:__automator_devops.interLogger
$logname = "builder"
# $kv = $global:__automator_devops.kvinc
#---UI ELEMENTS Shortened------------
$interLogger.invoke($logname, "Running Build on {kv:module=$ModuleName} ", $false, 'info')
if (!$build) {
$interLogger.invoke($logname, "Build is required all other build options", $false, 'error')
return;
}
# Remove dist folder if it exists
if ( test-path ".\dist" ){ remove-item ".\dist" -Recurse -Force -erroraction silentlycontinue }
else { New-Item -Path .\ -Name "dist" -ItemType Directory }
# NOTE: =====================================
# NOTE: LOCAL MACHINE ONLY WITH MODULES LOCATED IN G:\ AND /MNT/G/
# TODO: #1 Once all required modules are release, change to pull from the psgal or from gitlab directly
# TODO: #2
# local build on windows
# TODO: add included modules from Phellam-Automator for Consisitance once all depenancies are released, as above move to psgal or gitlab once released
if ($isWindows -and !$Automator) {
$interLogger.invoke($logname, "Importing local modules from 'G:\' {kv:ARC=Windows}", $false, 'info')
import-module -Name G:\devspace\projects\powershell\_repos\commitfusion\; # Get-GitAutoVerion extracted and used as standalone
import-module -name G:\devspace\projects\powershell\_repos\quicklog\;
import-module -name G:\devspace\projects\powershell\_repos\shelldock\;
import-module -name G:\devspace\projects\powershell\_repos\psmpacker\;
import-module -Name G:\devspace\projects\powershell\_repos\nupsforge\;
import-module -name G:\devspace\projects\powershell\_repos\csverify\;
}
# linux build
if ($isLinux -and !$Automator) {
$interlogger.invoke($logname, "Importing local modules from /mnt/g/devspace/projects/powershell/_repos/ {kv:ARC=Linux}", $false, 'info')
Import-Module -Name /mnt/g/devspace/projects/powershell/_repos/colorconsole/;
import-module -Name /mnt/g/devspace/projects/powershell/_repos/commitfusion/;
import-module -name /mnt/g/devspace/projects/powershell/_repos/quicklog/;
import-module -name /mnt/g/devspace/projects/powershell/_repos/shelldock/;
import-module -name /mnt/g/devspace/projects/powershell/_repos/psmpacker/;
import-module -Name /mnt/g/devspace/projects/powershell/_repos/nupsforge/;
import-module -name /mnt/g/devspace/projects/powershell/_repos/csverify/;
}
# docker phellams/automator
if ($Automator) {
$docker_image = "docker.io/sgkens/phellams-automator:$ENV:AUTOMATOR_VERSION"
$interLogger.invoke($logname, "Running Phellams-Automator on {kv:DockerImage=$docker_image}", $false, 'info')
[string]$scripts_to_run = ""
$build_Module = "./automator-devops/scripts/build/build-module.ps1;"
$build_dotnet_library = "./automator-devops/scripts/build/build-dotnet-library.ps1;"
$build_package_generic_nuget = "./automator-devops/scripts/build/build-package-generic-nuget.ps1;"
$build_choco_nuspec = "./automator-devops/scripts/build/build-nuspec-choco.ps1;"
$build_package_psgallery = "./automator-devops/scripts/build/build-package-psgallery.ps1;"
$build_package_choco = "./automator-devops/scripts/build/build-package-choco.sh"
$tools_phwriter_metadata = "./automator-devops/scripts/tools/generate-phwriter-metadata.ps1;"
$pester_test_script = "./automator-devops/scripts/test/test-pester-before-build.ps1;"
$SafeDirectory = "git config --global --add safe.directory /$ModuleName"
if ($pester) { $scripts_to_run += $pester_test_script } # psmodule
if ($build) { $scripts_to_run += $build_Module } # psmodule
if ($build_dotnet_lib) { $scripts_to_run += $build_dotnet_library } # .net
if ($psgal) { $scripts_to_run += $build_package_psgallery } # psmodule
if ($nuget) { $scripts_to_run += $build_package_generic_nuget } # psmodule, dotnet
if ($Phwriter) { $scripts_to_run += $tools_phwriter_metadata } # psmodule
if ($ChocoNuSpec) { $scripts_to_run += $build_choco_nuspec } # psmodule
if ($ChocoPackage) {
if(!$ChocoNuSpec -or !$build){
throw [System.Exception]::new("ChocoMonoPackage requires ChocoNuSpec and Build")
}
docker run --rm -v .:/$ModuleName $docker_image pwsh -c "cd /$modulename; $SafeDirectory; $scripts_to_run"
$docker_image = "docker.io/chocolatey/choco:latest"
$interLogger.invoke($logname, "Switching to Choco on {kv:DockerImage=$docker_image}", $false, 'info')
docker run --rm -v .:/$ModuleName $docker_image bash -c "cd /$modulename; $build_package_choco"
}else{
docker run --rm -v .:/$ModuleName $docker_image pwsh -c "cd /$modulename; $SafeDirectory; $scripts_to_run"
}
}
# =================================
# BUILD SCRIPTS
# =================================
if ($dotnet8_lib) { ./automator-devops/scripts/build/build-dotnet-library.ps1 }
if ($pester -and !$automator) { ./automator-devops/scripts/test/test-pester-before-build.ps1 }
if ($Sa -and !$automator) { ./automator-devops/scripts/test/test-sa-before-build.ps1 }
if ($build -and !$Automator) { ./automator-devops/scripts/build/build-module.ps1 }
if ($psgal -and !$Automator) { ./automator-devops/scripts/build/build-package-psgallery.ps1 }
if ($Nuget -and !$Automator) { ./automator-devops/scripts/build/build-package-generic-nuget.ps1 }
if ($ChocoNuSpec -and !$Automator) { ./automator-devops/scripts/build/Build-nuspec-choco.ps1 }
if ($ChocoPackageWindows -and !$Automator) { ./automator-devops/scripts/build/win-only/build-package-choco-windows.ps1 }
if ($cleanup) { ./automator-devops/run-cleanup.ps1 }
#TODO: add switch for clean up so it can be run sperately if needed
#TODO: move run-cleanup to scripts dir
# TEST DEPLOY
#./devops/scripts/deploy/deploy-gitlab.ps1
#./devops/scripts/deploy/deploy-psgallary.ps1
#./devops/scripts/deploy-extended-chocolatey.ps1
#./devops/scripts/create-tag.ps1