Skip to content
Merged
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
125 changes: 33 additions & 92 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,54 +266,27 @@ jobs:
Import-Module PowerShellGet -Force
Get-Module PowerShellGet | Select-Object Name, Version, Path | Format-List

- name: Build publishable module packages (multi-module for PSGallery)
- name: Build publishable module package (bundled IdLE)
shell: pwsh
run: |
./tools/New-IdleModulePackage.ps1 -Mode MultiModule -Clean | Format-List FullName
./tools/New-IdleModulePackage.ps1 -Clean | Format-List FullName

- name: Publish modules to local PSRepository and verify install/import
- name: Publish bundle to local PSRepository and verify install/import
shell: pwsh
run: |
$modulesPath = Join-Path $env:GITHUB_WORKSPACE 'artifacts/modules'
if (-not (Test-Path -LiteralPath $modulesPath)) {
throw "Staged modules path not found: $modulesPath"
}

# Ensure required modules are discoverable during Test-ModuleManifest/Publish-Module.
# Save original PSModulePath to restore before install/import verification.
$originalPSModulePath = $env:PSModulePath
$pathSeparator = [System.IO.Path]::PathSeparator
$modulePathEntries = $env:PSModulePath -split [regex]::Escape($pathSeparator)
if ($modulePathEntries -notcontains $modulesPath) {
$env:PSModulePath = $modulesPath + $pathSeparator + $env:PSModulePath
$packagePath = Join-Path $env:GITHUB_WORKSPACE 'artifacts/IdLE'
if (-not (Test-Path -LiteralPath $packagePath)) {
throw "Staged package path not found: $packagePath"
}

$repoPath = Join-Path $env:RUNNER_TEMP 'psrepo'
New-Item -ItemType Directory -Path $repoPath -Force | Out-Null

Register-PSRepository -Name 'LocalRepo' -SourceLocation $repoPath -PublishLocation $repoPath -InstallationPolicy Trusted

# Load publish order from configuration
$configPath = Join-Path $env:GITHUB_WORKSPACE 'tools/ModulePublishOrder.psd1'
$config = Import-PowerShellDataFile -LiteralPath $configPath
$publishOrder = $config.PublishOrder

Write-Host "Publishing modules in dependency order from configuration..."

foreach ($moduleName in $publishOrder) {
$modulePath = Join-Path $modulesPath $moduleName
if (-not (Test-Path -LiteralPath $modulePath)) {
throw "Module listed in ModulePublishOrder.psd1 not found: $moduleName at $modulePath. This indicates an incomplete build and must be fixed before release."
}

Write-Host "Publishing $moduleName..."
Publish-Module -Path $modulePath -Repository 'LocalRepo' -ErrorAction Stop
Write-Host " ✓ Published $moduleName"
}

# Restore original PSModulePath before install/import verification
# to ensure Import-Module resolves the installed package, not the staged build.
$env:PSModulePath = $originalPSModulePath
Write-Host "Publishing IdLE..."
Publish-Module -Path $packagePath -Repository 'LocalRepo' -ErrorAction Stop
Write-Host " ✓ Published IdLE"

# Test that IdLE can be installed and imports correctly
Write-Host "`nInstalling IdLE from LocalRepo..."
Expand All @@ -322,14 +295,20 @@ jobs:

$m = Get-Module IdLE
if (-not $m) { throw 'IdLE did not import successfully.' }
Write-Host "Imported IdLE: $($m.Name) $($m.Version)"
Write-Host "Imported IdLE: $($m.Name) $($m.Version) from $($m.ModuleBase)"

# Verify all bundled modules were loaded from the installed package
$expected = @((Import-PowerShellDataFile -LiteralPath (Join-Path $m.ModuleBase 'IdLE.psd1')).NestedModules |
ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension(($_ -replace '\\', '/')) })
foreach ($name in $expected) {
$nested = Get-Module -All -Name $name | Select-Object -First 1
if (-not $nested) { throw "$name was not loaded as nested module." }
if (-not $nested.ModuleBase.StartsWith($m.ModuleBase)) { throw "$name was loaded from '$($nested.ModuleBase)', not from the bundle." }
Write-Host " ✓ $name $($nested.Version)"
}

# Verify dependencies were installed
$core = Get-Module IdLE.Core
$steps = Get-Module IdLE.Steps.Common
if (-not $core) { throw 'IdLE.Core was not loaded as dependency.' }
if (-not $steps) { throw 'IdLE.Steps.Common was not loaded as dependency.' }
Write-Host "Dependencies loaded: IdLE.Core $($core.Version), IdLE.Steps.Common $($steps.Version)"
$factory = Get-Command -Module IdLE -Name 'New-IdleMockIdentityProvider' -ErrorAction SilentlyContinue
if (-not $factory) { throw 'IdLE does not export the provider factory functions.' }

Unregister-PSRepository -Name 'LocalRepo' -ErrorAction SilentlyContinue

Expand Down Expand Up @@ -369,12 +348,12 @@ jobs:
Import-Module PowerShellGet -Force
Get-Module PowerShellGet | Select-Object Name, Version, Path | Format-List

- name: Build publishable module packages (multi-module for PSGallery)
- name: Build publishable module package (bundled IdLE)
shell: pwsh
run: |
./tools/New-IdleModulePackage.ps1 -Mode MultiModule -Clean | Format-List FullName
./tools/New-IdleModulePackage.ps1 -Clean | Format-List FullName

- name: Publish modules to PSGallery
- name: Publish IdLE to PSGallery
shell: pwsh
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
Expand All @@ -383,52 +362,14 @@ jobs:
throw "Missing secret PSGALLERY_API_KEY."
}

$modulesPath = Join-Path $env:GITHUB_WORKSPACE 'artifacts/modules'
if (-not (Test-Path -LiteralPath $modulesPath)) {
throw "Staged modules path not found: $modulesPath"
}

# Ensure required modules are discoverable during Test-ModuleManifest/Publish-Module.
$pathSeparator = [System.IO.Path]::PathSeparator
$modulePathEntries = $env:PSModulePath -split [regex]::Escape($pathSeparator)
if ($modulePathEntries -notcontains $modulesPath) {
$env:PSModulePath = $modulesPath + $pathSeparator + $env:PSModulePath
$packagePath = Join-Path $env:GITHUB_WORKSPACE 'artifacts/IdLE'
$manifest = Join-Path $packagePath 'IdLE.psd1'
if (-not (Test-Path -LiteralPath $manifest)) {
throw "Staged package manifest not found: $manifest"
}

# Load publish order from configuration
$configPath = Join-Path $env:GITHUB_WORKSPACE 'tools/ModulePublishOrder.psd1'
$config = Import-PowerShellDataFile -LiteralPath $configPath
$publishOrder = $config.PublishOrder

Write-Host "Publishing modules to PowerShell Gallery in dependency order..."
Write-Host "==================================================================`n"

foreach ($moduleName in $publishOrder) {
$modulePath = Join-Path $modulesPath $moduleName
if (-not (Test-Path -LiteralPath $modulePath)) {
throw "Module listed in ModulePublishOrder.psd1 not found: $moduleName at $modulePath. This indicates an incomplete build and must be fixed before publishing to PSGallery."
}

$manifest = Join-Path $modulePath "$moduleName.psd1"
if (-not (Test-Path -LiteralPath $manifest)) {
throw "Module manifest not found: $manifest"
}

$data = Import-PowerShellDataFile -LiteralPath $manifest
Write-Host "Publishing: $moduleName Version: $($data.ModuleVersion)"

try {
Publish-Module -Path $modulePath -NuGetApiKey $env:PSGALLERY_API_KEY -Repository PSGallery -ErrorAction Stop
Write-Host " ✓ Successfully published $moduleName`n"

# Brief delay to allow PSGallery to process the module before publishing dependents
Start-Sleep -Seconds 30
}
catch {
Write-Error "Failed to publish $moduleName : $_"
throw
}
}
$data = Import-PowerShellDataFile -LiteralPath $manifest
Write-Host "Publishing: IdLE Version: $($data.ModuleVersion)"

Write-Host "==================================================================`n"
Write-Host "All modules published successfully!"
Publish-Module -Path $packagePath -NuGetApiKey $env:PSGALLERY_API_KEY -Repository PSGallery -ErrorAction Stop
Write-Host " ✓ Successfully published IdLE"
69 changes: 24 additions & 45 deletions docs/develop/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ IdLE follows [Semantic Versioning](https://semver.org/):

### Multi-Module Versioning Strategy

Starting with version 1.0, IdLE uses a **synchronized versioning strategy** across all published modules:
IdLE uses a **synchronized versioning strategy** across all modules. All modules are shipped together in the
bundled `IdLE` package (see [PowerShell Gallery publishing](#powershell-gallery-publishing)):

- All modules (`IdLE`, `IdLE.Core`, `IdLE.Steps.Common`, providers, and step modules) share the **same version number**
- Version bumps are **synchronized** across all modules in each release
Expand Down Expand Up @@ -223,64 +224,42 @@ If you need another preview, repeat with `preview.2`, etc. (no version bump requ

### PowerShell Gallery publishing

IdLE is published to the PowerShell Gallery as **multiple separate modules** (multi-module distribution):
IdLE is published to the PowerShell Gallery as **one package**, `IdLE`. It contains all first-party modules
(`IdLE.Core`, the `IdLE.Steps.*` step packs and the `IdLE.Provider.*` providers) as nested modules.

- **IdLE** (meta-module) — Declares `IdLE.Core` and `IdLE.Steps.Common` as `RequiredModules`
- **IdLE.Core** — Workflow engine (no IdLE dependencies)
- **IdLE.Steps.Common** — Built-in steps (requires `IdLE.Core`)
- **IdLE.Provider.\*** — Provider modules (each published separately, typically require `IdLE.Core`)
- **IdLE.Steps.\*** — Optional step modules (published separately, require `IdLE.Core` and/or `IdLE.Steps.Common`)

**Publishing Order:**

Modules are published in **dependency order** to ensure dependencies exist before dependent modules:

1. `IdLE.Core` (no IdLE dependencies)
2. `IdLE.Steps.Common` (depends on Core)
3. `IdLE` (depends on Core + Steps.Common)
4. All providers and optional step modules

The publish order is defined in `tools/ModulePublishOrder.psd1` and used by the release workflow.
The bundle content is defined by the `NestedModules` list in `src/IdLE/IdLE.psd1` (single source of truth).

**Workflow Behavior:**

- On tag pushes matching `v*`, the workflow publishes all modules to PSGallery in dependency order.
- A 30-second delay is added between publishes to allow PSGallery processing time.
- On tag pushes matching `v*`, the workflow publishes the `IdLE` package to PSGallery.
- For manual runs (`workflow_dispatch`), publishing is only performed when **publish_psgallery** is set to `true`.
- Before publishing, the `psgallery_local_test` job publishes the package to a local PSRepository, installs and imports it,
and verifies that all bundled modules are loaded from the installed package.

### Package staging

The workflow does not publish directly from the repository `src/` layout. Instead it stages publishable packages using:
:::note Discontinued standalone packages
Up to v0.9.x, every module was published as a separate package (`IdLE.Core`, `IdLE.Provider.AD`, …).
These packages are discontinued. After the first bundled release, the package owner unlists them manually on the PowerShell Gallery.
:::

- `tools/New-IdleModulePackage.ps1 -Mode MultiModule`
### Package staging

**Packaging modes:**
The workflow does not publish directly from the repository `src/` layout. Instead it stages the publishable package using:

1. **Bundled Mode** (`-Mode Bundled`, default):
- Creates a single package with nested modules under `Modules/`
- Output: `artifacts/IdLE/`
- Used for legacy distribution (GitHub releases, zip archives)
- `tools/New-IdleModulePackage.ps1`

2. **MultiModule Mode** (`-Mode MultiModule`):
- Creates separate packages for each module
- Output: `artifacts/modules/<ModuleName>/`
- Used for PowerShell Gallery publishing
- **Manifest transformation for IdLE:**
- Converts `NestedModules` with relative paths → `RequiredModules` with module names
- Removes `ScriptsToProcess` entry
- Removes `IdLE.Init.ps1` file (not needed in published packages)
The tool:

**Why transform manifests?**
- copies `src/IdLE/` to `artifacts/IdLE/` (package root),
- copies every module listed in `NestedModules` to `artifacts/IdLE/Modules/<Name>/`,
- rewrites the staged `NestedModules` entries from `..\<Name>\<Name>.psd1` to `.\Modules\<Name>\<Name>.psd1`.

- **Source manifests** use `NestedModules` with relative paths to support direct import from repository/zip: `Import-Module ./src/IdLE/IdLE.psd1`
- **Published manifests** use `RequiredModules` with module names for standard PowerShell dependency resolution when installed via `Install-Module`
The repository layout stays unchanged: every module keeps its own folder and manifest under `src/`, so contributors can
import directly from source with `Import-Module ./src/IdLE/IdLE.psd1`.

This dual-manifest approach ensures:
- ✅ Contributors can work directly from repository source
- ✅ Published modules follow PowerShell best practices
- ✅ No `$env:PSModulePath` configuration required for either scenario
**Mixed-version guard:** `IdLE.Init.ps1` (`ScriptsToProcess`) rejects the import if a standalone `IdLE.*` module that is
not part of the imported bundle is already loaded in the session.

For details on the architecture, see **[Installation Guide](../use/installation.md#multi-module-architecture)**.
For the user-facing view, see **[Installation Guide](../use/installation.md)**.

## Versioning and naming

Expand Down
5 changes: 5 additions & 0 deletions docs/reference/cmdlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ This page links the generated per-cmdlet reference pages and includes their syno
| --- | --- |
| [Export-IdlePlan](cmdlets/Export-IdlePlan.md) | Exports an IdLE LifecyclePlan as a canonical JSON artifact. |
| [Invoke-IdlePlan](cmdlets/Invoke-IdlePlan.md) | Executes an IdLE plan. |
| [New-IdleADIdentityProvider](cmdlets/New-IdleADIdentityProvider.md) | Creates an Active Directory identity provider for IdLE. |
| [New-IdleAuthSession](cmdlets/New-IdleAuthSession.md) | Creates a simple AuthSessionBroker for use with IdLE providers. |
| [New-IdleEntraConnectDirectorySyncProvider](cmdlets/New-IdleEntraConnectDirectorySyncProvider.md) | Creates an Entra Connect directory sync provider for IdLE. |
| [New-IdleEntraIDIdentityProvider](cmdlets/New-IdleEntraIDIdentityProvider.md) | Creates a Microsoft Entra ID identity provider for IdLE. |
| [New-IdleExchangeOnlineProvider](cmdlets/New-IdleExchangeOnlineProvider.md) | Creates an Exchange Online mailbox provider for IdLE. |
| [New-IdleMockIdentityProvider](cmdlets/New-IdleMockIdentityProvider.md) | Creates an in-memory identity provider for tests and demos. |
| [New-IdlePlan](cmdlets/New-IdlePlan.md) | Creates a deterministic plan from a lifecycle request and a workflow definition. |
| [New-IdleRequest](cmdlets/New-IdleRequest.md) | Creates a lifecycle request object. |
| [Test-IdleWorkflow](cmdlets/Test-IdleWorkflow.md) | Validates an IdLE workflow definition file. |
6 changes: 3 additions & 3 deletions docs/reference/cmdlets/Export-IdlePlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ string when writing a file.

### EXAMPLE 1
```
$plan = New-IdlePlan -Request $request -Workflow $workflow -StepRegistry $registry
$plan = New-IdlePlan -WorkflowPath ./joiner.psd1 -Request $request -Providers $providers
$plan | Export-IdlePlan
```

Exports the plan and returns the JSON string.

### EXAMPLE 2
```
New-IdlePlan -Request $request -Workflow $workflow -StepRegistry $registry |
New-IdlePlan -WorkflowPath ./joiner.psd1 -Request $request -Providers $providers |
Export-IdlePlan -Path ./artifacts/plan.json
```

Exports the plan and writes the JSON to a file.

### EXAMPLE 3
```
New-IdlePlan -Request $request -Workflow $workflow -StepRegistry $registry |
New-IdlePlan -WorkflowPath ./joiner.psd1 -Request $request -Providers $providers |
Export-IdlePlan -Path ./artifacts/plan.json -PassThru
```

Expand Down
Loading
Loading