From 6d20cec2ec464011f445dbbf275ac91fe2f65d17 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Wed, 30 Sep 2026 17:28:49 -0600 Subject: [PATCH 1/3] Add test for create-draft-release-with-notes-action --- .../action.yml | 23 +++++++- .github/workflows/CI-actions.yml | 12 +--- .../test-create-draft-release-with-assets.yml | 59 +++++++++++++++++++ 3 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test-create-draft-release-with-assets.yml diff --git a/.github/actions/create-draft-release-with-assets/action.yml b/.github/actions/create-draft-release-with-assets/action.yml index 87a67dc..9784ce7 100644 --- a/.github/actions/create-draft-release-with-assets/action.yml +++ b/.github/actions/create-draft-release-with-assets/action.yml @@ -4,16 +4,37 @@ inputs: asset-paths: required: true description: Comma-separated paths/globs passed to Get-ChildItem, e.g. "nugets/, powershellModules/, assets/" + dry-run: + required: false + default: 'false' + description: If true, skips creating the real draft release and only logs what would have been created. +outputs: + assets: + description: Comma-separated list of resolved asset file paths that were (or would be) attached + value: ${{ steps.create.outputs.assets }} runs: using: composite steps: - name: Create draft release and attach assets + id: create shell: pwsh run: | $paths = '${{ inputs.asset-paths }}' -split ',' | ForEach-Object { $_.Trim() } $assets = (Get-ChildItem -Path $paths -File -Recurse).FullName Write-Output "Assets to attach: $assets" Write-Output "Creating draft release for ${{ github.event.repository.name }} ${{ github.ref_name }} at commit ${{ github.sha }}" - gh release create ${{ github.ref_name }} $assets -d -n "" -t "${{ github.ref_name }}" + + if ('${{ inputs.dry-run }}' -eq 'true') + { + Write-Output "[dry-run] Skipping gh release create." + } + else + { + gh release create ${{ github.ref_name }} $assets -d -n "" -t "${{ github.ref_name }}" + } + + # -join keeps this on one line; $GITHUB_OUTPUT is line-based and a multi-line value would corrupt it. + $assetsJoined = $assets -join ',' + echo "assets=$assetsJoined" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf-8 -Append env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/CI-actions.yml b/.github/workflows/CI-actions.yml index 0546aa1..fd29f82 100644 --- a/.github/workflows/CI-actions.yml +++ b/.github/workflows/CI-actions.yml @@ -7,19 +7,13 @@ on: paths: - '.github/actions/**' jobs: - test-actions: - runs-on: ubuntu-latest - defaults: - run: - shell: pwsh - steps: - - name: Placeholder - run: echo "Placeholder for testing actions" + test-create-draft-release-with-assets: + uses: ./.github/workflows/test-create-draft-release-with-assets.yml validate-action-tests: # So we can add new tests without having to update branch protection rules name: Validate action test results - needs: [test-actions] + needs: [test-create-draft-release-with-assets] if: always() runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/test-create-draft-release-with-assets.yml b/.github/workflows/test-create-draft-release-with-assets.yml new file mode 100644 index 0000000..eb4293e --- /dev/null +++ b/.github/workflows/test-create-draft-release-with-assets.yml @@ -0,0 +1,59 @@ +name: Test - create-draft-release-with-assets +on: + workflow_call: +jobs: + test-create-draft-release-with-assets: + name: create-draft-release-with-assets / dry run + runs-on: ubuntu-latest + defaults: + run: + shell: pwsh + steps: + - name: Checkout + uses: actions/checkout@v7.0.1 + - name: Prepare test assets + run: | + New-Item -ItemType Directory -Path test-assets/dir1/nested -Force | Out-Null + New-Item -ItemType Directory -Path test-assets/dir2 -Force | Out-Null + Set-Content -Path test-assets/dir1/file-a.txt -Value 'asset a' + Set-Content -Path test-assets/dir1/nested/file-b.txt -Value 'asset b' + Set-Content -Path test-assets/dir2/file-c.txt -Value 'asset c' + - name: Create draft release and attach assets + id: create + uses: ./.github/actions/create-draft-release-with-assets + with: + asset-paths: test-assets/dir1, test-assets/dir2 + dry-run: true + - name: Verify resolved assets + run: | + $assets = '${{ steps.create.outputs.assets }}' -split ',' + Write-Output "Resolved assets: $assets" + + if ($assets.Count -ne 3) + { + throw "Expected 3 resolved assets (including the nested one), got $($assets.Count): $assets" + } + + foreach ($expected in @('test-assets/dir1/file-a.txt', 'test-assets/dir1/nested/file-b.txt', 'test-assets/dir2/file-c.txt')) + { + $expectedFullPath = (Resolve-Path $expected).Path + if ($assets -notcontains $expectedFullPath) + { + throw "Expected assets to include '$expected', got: $assets" + } + } + + Write-Output "OK" + - name: Verify no real release was created + run: | + gh release view '${{ github.ref_name }}' 2>$null + if ($LASTEXITCODE -eq 0) + { + throw "A real release for '${{ github.ref_name }}' exists even though dry-run was true." + } + Write-Output "OK: no real release exists for '${{ github.ref_name }}'" + env: + GH_TOKEN: ${{ github.token }} + - name: Clean up test assets + if: always() + run: Remove-Item -Path test-assets -Recurse -Force -ErrorAction SilentlyContinue From 59083c09646a0526f2f8cb7fa7fab43507ae8470 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Wed, 30 Sep 2026 17:33:58 -0600 Subject: [PATCH 2/3] Fix issue with expected failure setting LASTEXITCODE and making the test look like it failed --- .github/workflows/test-create-draft-release-with-assets.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-create-draft-release-with-assets.yml b/.github/workflows/test-create-draft-release-with-assets.yml index eb4293e..38bafde 100644 --- a/.github/workflows/test-create-draft-release-with-assets.yml +++ b/.github/workflows/test-create-draft-release-with-assets.yml @@ -52,6 +52,10 @@ jobs: throw "A real release for '${{ github.ref_name }}' exists even though dry-run was true." } Write-Output "OK: no real release exists for '${{ github.ref_name }}'" + + # gh release view above is expected to fail (exit non-zero) when no release exists - reset + # $LASTEXITCODE so that the expected failure doesn't show the test run as failed. + $global:LASTEXITCODE = 0 env: GH_TOKEN: ${{ github.token }} - name: Clean up test assets From 6ae9417c7195237c7cf26d8a95d2f395e76fa064 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Thu, 1 Oct 2026 15:32:45 -0600 Subject: [PATCH 3/3] Clean up job name --- .github/workflows/test-create-draft-release-with-assets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-create-draft-release-with-assets.yml b/.github/workflows/test-create-draft-release-with-assets.yml index 38bafde..684b1b7 100644 --- a/.github/workflows/test-create-draft-release-with-assets.yml +++ b/.github/workflows/test-create-draft-release-with-assets.yml @@ -3,7 +3,7 @@ on: workflow_call: jobs: test-create-draft-release-with-assets: - name: create-draft-release-with-assets / dry run + name: dry run runs-on: ubuntu-latest defaults: run: