mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 01:42:29 +00:00
Add more to build script for gitlabci
This commit is contained in:
parent
783c6b0a6a
commit
d421040192
1 changed files with 55 additions and 10 deletions
65
build.ps1
65
build.ps1
|
|
@ -2,6 +2,8 @@ param(
|
||||||
[string[]]$Tasks
|
[string[]]$Tasks
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Install-Dependency([string] $Name)
|
function Install-Dependency([string] $Name)
|
||||||
{
|
{
|
||||||
$policy = Get-PSRepository -Name "PSGallery" | Select-Object -ExpandProperty "InstallationPolicy"
|
$policy = Get-PSRepository -Name "PSGallery" | Select-Object -ExpandProperty "InstallationPolicy"
|
||||||
|
|
@ -31,6 +33,57 @@ function Run-Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Release
|
||||||
|
{
|
||||||
|
Write-Output "Setting Variables"
|
||||||
|
$BuildRoot = $env:CI_PROJECT_DIR
|
||||||
|
$releasePath = "$BuildRoot\Release"
|
||||||
|
|
||||||
|
Write-Output "Build Root : $BuildRoot"
|
||||||
|
Write-Output "Release Root : $releasePath"
|
||||||
|
|
||||||
|
if (-not (Test-Path "$releasePath\SnipeitPS")) {
|
||||||
|
$null = New-Item -Path "$releasePath\SnipeitPS" -ItemType Directory
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy module
|
||||||
|
Copy-Item -Path "$BuildRoot\SnipeitPS\*" -Destination "$releasePath\SnipeitPS" -Recurse -Force
|
||||||
|
# Copy additional files
|
||||||
|
$additionalFiles = @(
|
||||||
|
"$BuildRoot\CHANGELOG.md"
|
||||||
|
"$BuildRoot\LICENSE"
|
||||||
|
"$BuildRoot\README.md"
|
||||||
|
)
|
||||||
|
Copy-Item -Path $additionalFiles -Destination "$releasePath\SnipeitPS" -Force
|
||||||
|
|
||||||
|
|
||||||
|
$manifestContent = Get-Content -Path "$releasePath\SnipeitPS\SnipeitPS.psd1" -Raw
|
||||||
|
if ($manifestContent -notmatch '(?<=ModuleVersion\s+=\s+'')(?<ModuleVersion>.*)(?='')') {
|
||||||
|
throw "Module version was not found in manifest file,"
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentVersion = [Version] $Matches.ModuleVersion
|
||||||
|
if ($env:CI_JOB_ID) {
|
||||||
|
$newRevision = $env:CI_JOB_ID
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$newRevision = 0
|
||||||
|
}
|
||||||
|
$version = New-Object -TypeName System.Version -ArgumentList $currentVersion.Major,
|
||||||
|
$currentVersion.Minor,
|
||||||
|
$newRevision
|
||||||
|
|
||||||
|
Write-Output "New version : $version"
|
||||||
|
|
||||||
|
Update-Metadata -Path "$releasePath\SnipeitPS\SnipeitPS.psd1" -PropertyName ModuleVersion -Value $version
|
||||||
|
$functionsToExport = Get-ChildItem "$BuildRoot\SnipeitPS\SnipeitPS\Public" | ForEach-Object {$_.BaseName}
|
||||||
|
Set-ModuleFunctions -Name "$releasePath\SnipeitPS\SnipeitPS.psd1" -FunctionsToExport $functionsToExport
|
||||||
|
|
||||||
|
Remove-Module SnipeitPS
|
||||||
|
Import-Module $env:CI_PROJECT_DIR\SnipeitPS\SnipeitPS.psd1 -ErrorAction Stop
|
||||||
|
Publish-Module -Name SnipeitPS -Repository InternalPowerShellModules -NuGetApiKey 123456789
|
||||||
|
}
|
||||||
|
|
||||||
foreach($task in $Tasks){
|
foreach($task in $Tasks){
|
||||||
switch($task)
|
switch($task)
|
||||||
{
|
{
|
||||||
|
|
@ -41,16 +94,8 @@ foreach($task in $Tasks){
|
||||||
Run-Tests
|
Run-Tests
|
||||||
}
|
}
|
||||||
"release" {
|
"release" {
|
||||||
Register-PSRepository -Name InternalPowerShellModules `
|
Write-Output "Releasing..."
|
||||||
-SourceLocation http://192.168.1.155:81/nuget/DIPowerShell `
|
Release
|
||||||
-PackageManagementProvider NuGet `
|
|
||||||
-PublishLocation http://192.168.1.155:81/nuget/DIPowerShell `
|
|
||||||
-InstallationPolicy Trusted
|
|
||||||
|
|
||||||
Write-Output "Registerting Module"
|
|
||||||
|
|
||||||
Import-Module $env:CI_PROJECT_DIR\SnipeitPS\SnipeitPS.psd1 -ErrorAction Stop
|
|
||||||
Publish-Module -Name SnipeitPS -Repository InternalPowerShellModules -NuGetApiKey 123456789
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue