Skip to content

Decouple prerelease cleanup from the module artifact so Publish-Module succeeds on no-build PRs #376

Description

The Publish-Module job fails on pull requests that do not rebuild the module, because prerelease cleanup is bundled behind the module-artifact download inside the Publish-PSModule composite action. On a PR with no important changes, Build-Module is skipped (so no module artifact exists), yet Publish-Module still runs to clean up prereleases — and dies at actions/download-artifact before cleanup can execute.

Request

Current experience

On a PR that changes no important files (nothing matching ImportantFilePatterns, e.g. ^src/, ^README\.md$), the resolved settings are HasImportantChanges: falseRun.BuildModule: false, so Build-Module is skipped and the module artifact is never uploaded. The same PR still has Run.PublishModule: true with ReleaseType: None / CreateRelease: false — nothing is published; the job runs solely to clean up prereleases (as documented in workflow.yml: "Abandoned PR — Cleans up prereleases … no version published"). But PSModule/Publish-PSModule@v3.0.0 runs a fixed step sequence — Download module artifact (unconditional) → publish.ps1cleanup.ps1 — so the job fails at the first step:

##[error]Unable to download artifact(s): Artifact not found for name: module

Observed on PSModule/Template-PSModule#26 (run https://github.com/PSModule/Template-PSModule/actions/runs/29088726916/job/86348735543).

Desired experience

Prerelease cleanup runs successfully on PRs where the module was not rebuilt (no important changes) and on abandoned PRs, without requiring the module artifact.

Acceptance criteria

  • Publish-Module no longer fails when Build-Module was skipped and there is no module artifact
  • Prerelease cleanup runs independently of the module artifact and of publish.ps1
  • When a module is built and published, cleanup still excludes the just-published tag (current behavior preserved)
  • No module download / Gallery publish / GitHub Release is attempted when CreateRelease is false

Technical decisions

  • cleanup.ps1 needs none of the artifact — it only reads the PR head ref and calls gh release list / gh release delete. Its sole tie to publish is the step if: reading PSMODULE_PUBLISH_PSMODULE_CONTEXT_IsPrerelease (set by publish.ps1), which must be removed for standalone cleanup.
  • Publish-Module's needs: already excludes Build-Module, so the job is intended to run without a build; only the action's fixed step order prevents it.
  • Candidate approaches: (a) extract cleanup into its own job/step in Publish-Module.yml that does not download the artifact — preferred, and aligns with the SRP split in Publish-PSModule: Split Gallery publishing from GitHub Release creation #330; (b) make the artifact download + Gallery publish + Release creation conditional on CreateRelease while cleanup always runs.

Implementation plan

  • Move prerelease cleanup out of the publish path so it does not depend on download-artifact or publish.ps1
  • Gate the module download + Gallery publish + GitHub Release on an actual release being created (CreateRelease)
  • Compute the "exclude just-published tag" behavior without relying on publish.ps1 env vars (skip exclusion when nothing was published)
  • Ensure cleanup runs on no-build PRs and abandoned PRs

Testing

  • No-build PR (no important changes): Publish-Module succeeds and cleans up prereleases
  • Prerelease PR (with build): prerelease published, cleanup excludes the published tag
  • Merged PR to default branch: stable released, prior prereleases cleaned up
  • Abandoned PR: prereleases for the branch cleaned up, no publish attempted

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixgithub_actionsPull requests that update GitHub Actions code

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions