From 91bf06a50fee0c46c3b40e0f661115fca2278f87 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Wed, 30 Sep 2026 17:28:49 -0600 Subject: [PATCH 1/4] Add test for create-draft-release-with-notes-action --- .../action.yml | 19 +++++- .github/workflows/CI-actions.yml | 12 +--- .../test-create-draft-release-with-assets.yml | 59 +++++++++++++++++++ 3 files changed, 80 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 87c5e58..2a30496 100644 --- a/.github/actions/create-draft-release-with-assets/action.yml +++ b/.github/actions/create-draft-release-with-assets/action.yml @@ -5,16 +5,33 @@ inputs: default: 'nugets,assets' required: false description: Comma-separated paths where asset files are located + dry-run: + required: false + default: 'false' + description: If true, skips creating the real draft release and only logs what would have been created. 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 -LiteralPath ($paths.Where({Test-Path $_})) -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 4c4dbda235a7928fb736edf7528f13387d523d06 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Wed, 30 Sep 2026 17:33:58 -0600 Subject: [PATCH 2/4] 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 61f8ed2dbe0e97ae3f39c97a0fa7ca5cee27cff0 Mon Sep 17 00:00:00 2001 From: Nick Gallegos Date: Thu, 1 Oct 2026 15:32:45 -0600 Subject: [PATCH 3/4] 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: From 3b686f62c39f1c7eef1c107a782b429deb58fa8e Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 7 Oct 2026 17:41:05 -0400 Subject: [PATCH 4/4] Add outputs lost in rebase --- .../actions/create-draft-release-with-assets/action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/create-draft-release-with-assets/action.yml b/.github/actions/create-draft-release-with-assets/action.yml index 2a30496..d3de868 100644 --- a/.github/actions/create-draft-release-with-assets/action.yml +++ b/.github/actions/create-draft-release-with-assets/action.yml @@ -2,13 +2,16 @@ name: Create draft release with assets description: Creates a draft GitHub release and attaches asset files found under the given paths inputs: asset-paths: - default: 'nugets,assets' required: false + default: 'nugets,assets' description: Comma-separated paths where asset files are located 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: + value: ${{ steps.create.outputs.assets }} runs: using: composite steps: @@ -23,7 +26,7 @@ runs: if ('${{ inputs.dry-run }}' -eq 'true') { - Write-Output "[dry-run] Skipping gh release create." + Write-Output "[dry-run] Skipping gh release create" } else {