Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/publish-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact_name }}
path: artifacts/**/*.nupkg
path: |
artifacts/**/*.nupkg
artifacts/**/*.snupkg
4 changes: 3 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: nuget-packages
path: artifacts/**/*.nupkg
path: |
artifacts/**/*.nupkg
artifacts/**/*.snupkg
71 changes: 71 additions & 0 deletions .github/workflows/self-test-publish-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Self-test Publish Artifacts
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- .github/workflows/publish-release.yml
- .github/workflows/publish-preview.yml
- .github/workflows/self-test-publish-artifacts.yml
workflow_dispatch:

permissions:
contents: read

jobs:
upload:
runs-on: ubuntu-latest
strategy:
matrix:
workflow: [release, preview]
steps:
- uses: actions/checkout@v7
- name: Install PyYAML
run: python3 -m pip install --quiet pyyaml==6.0.2
- name: Prepare packages and read publishing paths
id: paths
env:
WORKFLOW: ${{ matrix.workflow }}
run: |
python3 - <<'PY'
import os
from pathlib import Path
import yaml

source = Path(f".github/workflows/publish-{os.environ['WORKFLOW']}.yml")
workflow = yaml.safe_load(source.read_text())
uploads = [step for job in workflow["jobs"].values() for step in job.get("steps", [])
if step.get("uses", "").startswith("actions/upload-artifact@")]
assert len(uploads) == 1, "Expected one publishing artifact upload"
paths = uploads[0]["with"]["path"]
Path("artifacts").mkdir()
for extension in ("nupkg", "snupkg"):
Path(f"artifacts/SelfTest.1.0.0.{extension}").write_text("fixture\n")
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
output.write(f"paths<<ARTIFACT_PATHS\n{paths}\nARTIFACT_PATHS\n")
PY
- uses: actions/upload-artifact@v7
with:
name: symbols-${{ matrix.workflow }}
path: ${{ steps.paths.outputs.paths }}
if-no-files-found: error
retention-days: 1

download:
needs: upload
runs-on: ubuntu-latest
strategy:
matrix:
workflow: [release, preview]
steps:
- uses: actions/download-artifact@v4
with:
name: symbols-${{ matrix.workflow }}
path: restored
- name: Verify package and symbols survived transfer
run: |
python3 - <<'PY'
from pathlib import Path
expected = {"SelfTest.1.0.0.nupkg", "SelfTest.1.0.0.snupkg"}
actual = {path.name for path in Path("restored").rglob("*") if path.is_file()}
assert actual == expected, f"Artifact transfer mismatch: {actual}"
PY
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ To satisfy the policy, the `NuGet/login` OIDC exchange must happen in a job that

### How it works

The `publish-preview.yml` and `publish-release.yml` shared workflows handle everything up to and including packing, then upload the `.nupkg` files as a GitHub Actions artifact. The caller is responsible for a separate `push` job that uses the `nuget-push` composite action:
The `publish-preview.yml` and `publish-release.yml` shared workflows handle everything up to and including packing, then upload the `.nupkg` and generated `.snupkg` files as a GitHub Actions artifact. The caller is responsible for a separate `push` job that uses the `nuget-push` composite action:

```
build job (shared workflow) → resolve version, build, test, pack, upload-artifact
Expand All @@ -278,10 +278,13 @@ Located at `.github/actions/nuget-push/action.yml`. Handles the full push flow i

1. Exchange GitHub OIDC token for a temporary NuGet API key via `NuGet/login@v1`
2. Download the `nuget-packages` artifact produced by the build job
3. Push all `.nupkg` files to NuGet.org
3. Push all `.nupkg` files to NuGet.org, including matching `.snupkg` files from the same directory

Because it is a **composite action** (not a reusable workflow), it runs inline inside the caller's job — so `job_workflow_ref` remains the caller's workflow path.

The publishing artifact self-test uploads the paths read from both workflows and verifies that
primary and symbol packages survive download. It does not publish to NuGet.

### Caller setup

Each repo's publish workflow needs a `push` job with `id-token: write` permission:
Expand Down
Loading