Skip to content

Publish-PSModule: Split Gallery publishing from GitHub Release creation #330

@MariusStorhaug

Description

Publish-PSModule bundles three distinct responsibilities into a single composite action: version calculation and release-type determination (init.ps1), PowerShell Gallery publishing and GitHub Release creation (publish.ps1), and prerelease cleanup (cleanup.ps1). Each responsibility has different triggers, different failure modes, and different consumers.

Request

Current experience

The action's publish.ps1 script (lines 106–216) performs two independent operations in sequence:

  1. Publish to PowerShell Gallery (lines 106–138): Updates the module manifest, calls Publish-PSResource, and comments on the PR
  2. Create GitHub Release (lines 140–216): Creates a tagged release with release notes and comments on the PR

These operations have independent failure modes:

  • Gallery publish can fail (API down, duplicate version, invalid manifest) while GitHub Release would succeed
  • GitHub Release can fail (permission issue, tag conflict) while Gallery publish already succeeded
  • There is no rollback if one succeeds and the other fails

Additionally, init.ps1 (407 lines) contains version calculation and release-type determination logic that is identical to Release-GHRepository (see #326).

Desired experience

Publish-PSModule has a single responsibility: publish a module to the PowerShell Gallery. GitHub Release creation is handled by Release-GHRepository (or a shared release action). Version calculation is handled by a shared versioning library (see #326).

Acceptance criteria

  • Publish-PSModule only publishes to the PowerShell Gallery
  • GitHub Release creation is handled by a separate action or workflow step
  • A Gallery publish failure does not prevent creating a GitHub Release (and vice versa)
  • Version calculation logic exists in exactly one place (shared with Release-GHRepository)
  • PR commenting for each operation is scoped to the responsible action

Note

This violates the Single Responsibility Principle (SRP). It is directly related to #210 (separate release from publish), #176 (move version generation to build), and #326 (extract shared versioning logic).

Related issues


Technical decisions

Approach: Refactor Publish-PSModule into a focused Gallery-publish action. The Publish-Module.yml workflow orchestrates the full publish pipeline by calling separate actions in sequence:

  1. Version calculation — shared module or action (from Extract shared versioning and release logic from Publish-PSModule and Release-GHRepository #326)
  2. Gallery publish — slimmed Publish-PSModule action
  3. GitHub ReleaseRelease-GHRepository action (already exists)
  4. Prerelease cleanup — shared cleanup function (from Extract shared versioning and release logic from Publish-PSModule and Release-GHRepository #326)

Breaking change: The Publish-PSModule action interface changes. Since it is only consumed by Publish-Module.yml within Process-PSModule, the blast radius is contained.

Dependency on #326: This issue depends on #326 (shared versioning logic) being completed first, or at least being designed concurrently. Without shared versioning, splitting the action just moves the duplication.


Implementation plan

Publish-PSModule action changes

  • Remove GitHub Release creation logic from publish.ps1
  • Remove version calculation logic from init.ps1 (replace with shared module call)
  • Remove prerelease cleanup logic from cleanup.ps1 (replace with shared module call)
  • Simplify action inputs to only Gallery-publish-relevant parameters
  • Retain: manifest update, Publish-PSResource call, Gallery-specific PR comment

Publish-Module.yml workflow changes

  • Add a step to call Release-GHRepository (or shared release action) after Gallery publish
  • Add a step for prerelease cleanup
  • Ensure Gallery publish failure does not block Release creation (independent if: conditions)

Testing

  • Verify Gallery publish still works in isolation
  • Verify GitHub Release is still created on merge
  • Verify prerelease cleanup still runs
  • Verify failure isolation — Gallery failure does not block Release, and vice versa

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions