Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ inputs:
Name:
description: Name of the module to process.
required: false
Version:
description: Module version to stamp into the manifest. When empty, the manifest version defaults to `999.0.0`.
required: false
Prerelease:
description: Prerelease tag to stamp into the manifest's `PrivateData.PSData.Prerelease`. When empty, no prerelease tag is written.
required: false
ArtifactName:
description: Name of the artifact to upload.
required: false
Expand All @@ -27,6 +33,8 @@ runs:
working-directory: ${{ inputs.WorkingDirectory }}
env:
PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }}
PSMODULE_BUILD_PSMODULE_INPUT_Version: ${{ inputs.Version }}
PSMODULE_BUILD_PSMODULE_INPUT_Prerelease: ${{ inputs.Prerelease }}
run: |
# Build-PSModule
${{ github.action_path }}/src/main.ps1
Expand Down
12 changes: 10 additions & 2 deletions src/helpers/Build-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@

# Path to the folder where the built modules are outputted.
[Parameter(Mandatory)]
[string] $ModuleOutputFolderPath
[string] $ModuleOutputFolderPath,

# Module version to stamp into the manifest. When empty, defaults to '999.0.0'.
[Parameter()]
[string] $ModuleVersion,

# Prerelease tag to stamp into the manifest. When empty, no prerelease tag is written.
[Parameter()]
[string] $ModulePrerelease
)

Set-GitHubLogGroup "Building module [$ModuleName]" {
Expand All @@ -40,7 +48,7 @@
}

Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder
Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder
Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder -ModuleVersion $ModuleVersion -ModulePrerelease $ModulePrerelease
Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder
Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder

Expand Down
20 changes: 15 additions & 5 deletions src/helpers/Build/Build-PSModuleManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@

# Folder where the built modules are outputted. 'outputs/modules/MyModule'
[Parameter(Mandatory)]
[System.IO.DirectoryInfo] $ModuleOutputFolder
[System.IO.DirectoryInfo] $ModuleOutputFolder,

# Module version to stamp into the manifest. When empty, defaults to '999.0.0'.
[Parameter()]
[string] $ModuleVersion,

# Prerelease tag to stamp into the manifest's `PrivateData.PSData.Prerelease`.
[Parameter()]
[string] $ModulePrerelease
)

Set-GitHubLogGroup 'Build manifest file' {
Expand All @@ -55,7 +63,7 @@
$manifest.RootModule = $rootModule
Write-Host "[RootModule] - [$($manifest.RootModule)]"

$manifest.ModuleVersion = '999.0.0'
$manifest.ModuleVersion = if ([string]::IsNullOrWhiteSpace($ModuleVersion)) { '999.0.0' } else { $ModuleVersion }
Write-Host "[ModuleVersion] - [$($manifest.ModuleVersion)]"

$manifest.Author = $manifest.Keys -contains 'Author' ? (-not [string]::IsNullOrEmpty($manifest.Author)) ? $manifest.Author : $env:GITHUB_REPOSITORY_OWNER : $env:GITHUB_REPOSITORY_OWNER
Expand Down Expand Up @@ -417,9 +425,11 @@
$manifest.Remove('ReleaseNotes')
}

Write-Host '[PreRelease]'
# $manifest.PreRelease = ""
# Is managed by the publish action
Write-Host '[Prerelease]'
if (-not [string]::IsNullOrWhiteSpace($ModulePrerelease)) {
$manifest.Prerelease = $ModulePrerelease
Write-Host "[Prerelease] - [$($manifest.Prerelease)]"
}

Write-Host '[RequireLicenseAcceptance]'
$manifest.RequireLicenseAcceptance = $PSData.Keys -contains 'RequireLicenseAcceptance' ? $null -ne $PSData.RequireLicenseAcceptance ? $PSData.RequireLicenseAcceptance : $false : $false
Expand Down
6 changes: 6 additions & 0 deletions src/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ Set-GitHubLogGroup 'Loading inputs' {
} else {
$env:PSMODULE_BUILD_PSMODULE_INPUT_Name
}
$moduleVersion = $env:PSMODULE_BUILD_PSMODULE_INPUT_Version
$modulePrerelease = $env:PSMODULE_BUILD_PSMODULE_INPUT_Prerelease
$sourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path
$moduleOutputFolderPath = Join-Path $pwd -ChildPath 'outputs/module'
[pscustomobject]@{
moduleName = $moduleName
moduleVersion = $moduleVersion
modulePrerelease = $modulePrerelease
sourceFolderPath = $sourceFolderPath
moduleOutputFolderPath = $moduleOutputFolderPath
} | Format-List | Out-String
Expand All @@ -47,6 +51,8 @@ $params = @{
ModuleName = $moduleName
ModuleSourceFolderPath = $sourceFolderPath
ModuleOutputFolderPath = $moduleOutputFolderPath
ModuleVersion = $moduleVersion
ModulePrerelease = $modulePrerelease
}
Build-PSModule @params

Expand Down