Skip to content

Commit 012b38c

Browse files
fix: use unique artifact names in test workflow and address review comments
- Add ArtifactName input to action.yml (default: module) so callers can specify the artifact name for download-artifact - Update Action-Test.yml to use unique artifact names (module-default, module-prerelease, module-unstamped) per job to avoid upload-artifact v7 name collision across parallel jobs - Add -PathType Container to Test-Path for module directory validation - Wrap Import-PowerShellDataFile in try/catch with actionable error message - Remove redundant notesFilePath cleanup after finally block
1 parent 464fbbd commit 012b38c

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/Action-Test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Upload module artifact
3030
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
3131
with:
32-
name: module
32+
name: module-default
3333
path: tests/outputs/module
3434

3535
- name: Action-Test
@@ -38,6 +38,7 @@ jobs:
3838
GITHUB_TOKEN: ${{ github.token }}
3939
with:
4040
Name: PSModuleTest
41+
ArtifactName: module-default
4142
WorkingDirectory: tests
4243
APIKey: ${{ secrets.APIKEY }} # zizmor: ignore[secrets-outside-env] saved in org secrets as an intentional choice
4344
WhatIf: true
@@ -83,7 +84,7 @@ jobs:
8384
- name: Upload module artifact
8485
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8586
with:
86-
name: module
87+
name: module-prerelease
8788
path: tests/outputs/module-prerelease
8889

8990
- name: Action-Test
@@ -92,6 +93,7 @@ jobs:
9293
GITHUB_TOKEN: ${{ github.token }}
9394
with:
9495
Name: PSModuleTest
96+
ArtifactName: module-prerelease
9597
ModulePath: outputs/module-prerelease
9698
WorkingDirectory: tests
9799
APIKey: ${{ secrets.APIKEY }} # zizmor: ignore[secrets-outside-env] saved in org secrets as an intentional choice
@@ -142,7 +144,7 @@ jobs:
142144
- name: Upload module artifact
143145
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
144146
with:
145-
name: module
147+
name: module-unstamped
146148
path: tests/outputs/module-unstamped
147149

148150
- name: Action-Test
@@ -153,6 +155,7 @@ jobs:
153155
GITHUB_TOKEN: ${{ github.token }}
154156
with:
155157
Name: PSModuleTest
158+
ArtifactName: module-unstamped
156159
ModulePath: outputs/module-unstamped
157160
WorkingDirectory: tests
158161
APIKey: ${{ secrets.APIKEY }} # zizmor: ignore[secrets-outside-env] saved in org secrets as an intentional choice

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ inputs:
3737
description: When enabled along with UsePRBodyAsReleaseNotes, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will reference the pull request number.
3838
required: false
3939
default: 'true'
40+
ArtifactName:
41+
description: Name of the uploaded artifact to download. Must match the name used in the upstream upload-artifact step.
42+
required: false
43+
default: module
4044

4145
runs:
4246
using: composite
@@ -52,7 +56,7 @@ runs:
5256
- name: Download module artifact
5357
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5458
with:
55-
name: module
59+
name: ${{ inputs.ArtifactName }}
5660
path: ${{ inputs.ModulePath }}
5761

5862
- name: Publish Module

src/publish.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LogGroup 'Load inputs' {
4747
} else {
4848
Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $modulePathInput -AdditionalChildPath $name
4949
}
50-
if (-not (Test-Path -Path $modulePathCandidate)) {
50+
if (-not (Test-Path -Path $modulePathCandidate -PathType Container)) {
5151
Write-Error ("Module directory not found at [$modulePathCandidate]. " +
5252
'Ensure the artifact contains a <ModulePath>/<Name>/ subdirectory layout.')
5353
exit 1
@@ -99,7 +99,12 @@ LogGroup 'Resolve version from manifest' {
9999
Write-Host '::warning::Test-ModuleManifest returned warnings (e.g. unresolved RequiredModules). Continuing with data-file validation.'
100100
}
101101

102-
$manifestData = Import-PowerShellDataFile -Path $manifestFilePath
102+
try {
103+
$manifestData = Import-PowerShellDataFile -Path $manifestFilePath
104+
} catch {
105+
Write-Error "Failed to import manifest data file [$manifestFilePath]: $($_.Exception.Message)"
106+
exit 1
107+
}
103108
$moduleVersion = $manifestData.ModuleVersion
104109
if (-not ($moduleVersion -match '^\d+\.\d+\.\d+$')) {
105110
Write-Error ("ModuleVersion [$moduleVersion] must be in Major.Minor.Patch format. " +
@@ -237,10 +242,6 @@ LogGroup 'Create GitHub release' {
237242
}
238243
}
239244

240-
if ($notesFilePath -and (Test-Path -Path $notesFilePath)) {
241-
Remove-Item -Path $notesFilePath -Force
242-
}
243-
244245
# Attach the built module as a release artifact so consumers can download the exact
245246
# bytes that were tested and published to the PowerShell Gallery.
246247
$zipFileName = "$name-$publishPSVersion.zip"

0 commit comments

Comments
 (0)