Skip to content

Commit

Permalink
Migrate build to 'endjin-devops'
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDawson committed Oct 8, 2024
1 parent 7eb4444 commit 0679381
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 64 deletions.
42 changes: 42 additions & 0 deletions .devops/config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$devopsExtensions = @(
@{
Name = "Endjin.RecommendedPractices.Build"
Version = "[1.5.10,2.0)"
Process = "tasks/build.process.ps1"
}
)

# Load the tasks and process
. endjin-devops.tasks

#
# Build process configuration
#
$SolutionToBuild = (Resolve-Path (Join-Path $here "./Solutions/Ais.Net.Models.sln")).Path


# Set default build task
task . FullBuild

#
# Build Process Extensibility Points - uncomment and implement as required
#

# task RunFirst {}
# task PreInit {}
# task PostInit {}
# task PreVersion {}
# task PostVersion {}
# task PreBuild {}
# task PostBuild {}
# task PreTest {}
# task PostTest {}
# task PreTestReport {}
# task PostTestReport {}
# task PreAnalysis {}
# task PostAnalysis {}
# task PrePackage {}
# task PostPackage {}
# task PrePublish {}
# task PostPublish {}
# task RunLast {}
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
BUILDVAR_NuGetPublishSource: "${{ startsWith(github.ref, 'refs/tags/') && 'https://api.nuget.org/v3/index.json' || 'https://nuget.pkg.github.com/ais-dotnet/index.json' }}"
BUILDVAR_Configuration: "Release"
secretsYaml: |
NUGET_API_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.NUGET_APIKEY || secrets.GITHUB_PUBLISHER_PAT }}"
NUGET_API_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.NUGET_APIKEY || secrets.BUILD_PUBLISHER_PAT }}"
build:
needs: prepareConfig
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,8 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# Build outputs
_codeCoverage/
_packages/
*.sbom.*
102 changes: 39 additions & 63 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@
the build process.
.PARAMETER Tasks
Optionally override the default task executed as the entry-point of the build.
.PARAMETER ContainerRegistryType
The type of container registry to use when publishing any images (supported values: acr,docker,ghcr)
.PARAMETER ContainerRegistryFqdn
The fully-qualified domain name for the target container registry
.PARAMETER Configuration
The build configuration, defaults to 'Release'.
.PARAMETER BuildRepositoryUri
Optional URI that supports pulling MSBuild logic from a web endpoint (e.g. a GitHub blob).
.PARAMETER SourcesDir
The path where the source code to be built is located, defaults to the current working directory.
.PARAMETER CoverageDir
The output path for the test coverage data, if run.
.PARAMETER TestReportTypes
The test report format that should be generated by the test report generator, if run.
.PARAMETER PackagesDir
The output path for any packages produced as part of the build.
.PARAMETER LogLevel
The logging verbosity.
.PARAMETER Clean
When true, the .NET solution will be cleaned and all output/intermediate folders deleted.
.PARAMETER BuildModulePath
The path to import the Endjin.RecommendedPractices.Build module from. This is useful when
testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet
Expand All @@ -36,42 +44,47 @@ param (
[string[]] $Tasks = @("."),

[Parameter()]
[ValidateSet("", "docker", "acr", "ghcr")]
[string] $ContainerRegistryType = "acr",
[string] $Configuration = "Debug",

[Parameter()]
[string] $ContainerRegistryFqdn = "",
[string] $BuildRepositoryUri = "",

[Parameter()]
[string] $SourcesDir = $PWD,

[Parameter()]
[string] $CoverageDir = "_codeCoverage",

[Parameter()]
[string] $TestReportTypes = "Cobertura",

[Parameter()]
[string] $PackagesDir = "_packages",

[Parameter()]
[ValidateSet("minimal","normal","detailed")]
[string] $LogLevel = "minimal",

[Parameter()]
[string] $Configuration = "Debug",
[switch] $Clean,

[Parameter()]
[string] $BuildModulePath,

[Parameter()]
[string] $BuildModuleVersion = "1.5.10-beta0003",
[string] $BuildModuleVersion = "1.0.0-preview0020",

[Parameter()]
[version] $InvokeBuildModuleVersion = "5.10.3"
[version] $InvokeBuildModuleVersion = "5.11.3"
)

$ErrorActionPreference = $ErrorActionPreference ? $ErrorActionPreference : 'Stop'
$InformationPreference = 'Continue'

$ErrorActionPreference = 'Stop'
$here = Split-Path -Parent $PSCommandPath

#region InvokeBuild setup
# This handles calling the build engine when this file is run like a normal PowerShell script
# (i.e. avoids the need to have another script to setup the InvokeBuild environment and issue the 'Invoke-Build' command )
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Install-PSResource InvokeBuild -Version $InvokeBuildModuleVersion -Scope CurrentUser -TrustRepository | Out-Null
Install-PSResource InvokeBuild -Version $InvokeBuildModuleVersion -Scope CurrentUser -TrustRepository -Verbose:$false | Out-Null
try {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
}
Expand All @@ -94,57 +107,20 @@ if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
#endregion

#region Import shared tasks and initialise build framework
$splat = @{ Force = $true; Verbose = $false}
if (!($BuildModulePath)) {
Install-PSResource Endjin.RecommendedPractices.Build -Version $BuildModuleVersion -Scope CurrentUser -TrustRepository | Out-Null
$BuildModulePath = "Endjin.RecommendedPractices.Build"
Install-PSResource endjin-devops -Version $BuildModuleVersion -Scope CurrentUser -TrustRepository -Reinstall:$($BuildModuleVersion -match '-') | Out-Null
$BuildModulePath = "endjin-devops"
$splat.Add("RequiredVersion", ($BuildModuleVersion -split '-')[0])
}
else {
Write-Information "BuildModulePath: $BuildModulePath"
Write-Host "BuildModulePath: $BuildModulePath"
}
Import-Module $BuildModulePath -RequiredVersion ($BuildModuleVersion -split '-')[0] -Force
Write-Host "Using Build module version: $((Get-Module Endjin.RecommendedPractices.Build | Select-Object -ExpandProperty Version).ToString())"

# Load the build process & tasks
. Endjin.RecommendedPractices.Build.tasks
$splat.Add("Name", $BuildModulePath)
Import-Module @splat
$ver = "{0} {1}" -f (Get-Module endjin-devops).Version, (Get-Module endjin-devops).PrivateData.PsData.PreRelease
Write-Host "Using Build module version: $ver"
#endregion

#
# Build process control options
#
$SkipInit = $false
$SkipVersion = $false
$SkipBuild = $false
$CleanBuild = $false
$SkipTest = $false
$SkipTestReport = $false
$SkipAnalysis = $false
$SkipPackage = $false
$SkipPublish = $false

#
# Build process configuration
#
$SolutionToBuild = (Resolve-Path (Join-Path $here "./Solutions/Ais.Net.Models.sln")).Path

# Synopsis: Build, Test and Package
task . FullBuild

# build extensibility tasks
task RunFirst {}
task PreInit {}
task PostInit {}
task PreVersion {}
task PostVersion {}
task PreBuild {}
task PostBuild {}
task PreTest {}
task PostTest {}
task PreTestReport {}
task PostTestReport {}
task PreAnalysis {}
task PostAnalysis {}
task PrePackage {}
task PostPackage {}
task PrePublish {}
task PostPublish {}
task RunLast {}
# Load the build configuration
. $here/.devops/config.ps1

0 comments on commit 0679381

Please sign in to comment.