Skip to content
Merged
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
23 changes: 23 additions & 0 deletions .claude/agent-memory/MEMORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Agent Memory

## Feedback

### NuGet .snupkg push to NuGet.org
When reviewing `dotnet nuget push` steps targeting nuget.org, do NOT flag the absence of a separate `*.snupkg` push step. NuGet.org automatically detects and ingests the `.snupkg` symbol package when the corresponding `.nupkg` is pushed.

### Dependabot NuGet PRs and the no-release label
NuGet Dependabot PRs in `dependabot.yml` intentionally omit the `no-release` label. NuGet dependency bumps are deliberately release-worthy so consumers get updated packages. Do NOT flag this as missing.

### ItemTests.ATest is an intentional placeholder
The test `ATest` in `examples/MinimalWebApi/tests/MinimalWebApi.Tests.Api/Schema/ItemTests.cs` is a deliberate minimal placeholder — the example project needs at least one unit test to exercise the CI pipeline. Do NOT flag it as trivial, low-quality, or missing real assertions.

### example-pr.yml is-release-branch: false is intentional
The hardcoded `is-release-branch: false` in `.github/workflows/example-pr.yml` is intentional. This example project must never auto-release to NuGet.org. Do NOT flag the commented-out expression or the hardcoded false as an issue.

### example-pr.yml workflow_dispatch is intentional
`workflow_dispatch` on `example-pr.yml` (and the commented-out `force-release` input) is by design — it exists for manual testing of the PR workflow. The example must never release to NuGet.org regardless. Do NOT flag `workflow_dispatch` on PR workflows or silently-ignored `force-release` as an issue in example workflows.

## Project Context

### Workflow secrets are caller-provided, not repo-owned
The secrets declared in `workflow_call.secrets:` blocks (e.g. `GITHUB_TOKEN`, `NUGET_API_KEY`, `CODECOV_TOKEN`) represent tokens that **calling repositories** provide when they consume these workflow templates — they are not secrets belonging to this repo. When analysing or fixing secrets-related issues, account for the fact that these workflows are reusable templates consumed by other GitHub projects, and the tokens are scoped to those caller repos.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ updates:
patterns:
- "AwesomeAssertions*"
- "coverlet*"
- "FakeItEasy*"
- "GitHubActionsTestLogger"
- "xunit*"
update-types: ["minor", "patch"]
Expand Down Expand Up @@ -83,7 +82,6 @@ updates:
patterns:
- "AwesomeAssertions*"
- "coverlet*"
- "FakeItEasy*"
- "GitHubActionsTestLogger"
- "xunit*"
update-types: ["minor", "patch"]
6 changes: 6 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ changelog:
- title: Dependency Updates 🎳
labels:
- dependencies
- title: Documentation 📖
labels:
- documentation
- title: Configuration & CI ⚙️
labels:
- configuration
- title: Other 📝
labels:
- "*"
41 changes: 29 additions & 12 deletions .github/workflows/_check-release-eligibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: check-release-eligibility
on:
workflow_call:
inputs:
harden-runner-policy:
description: "The egress policy for the Harden Runner step. Defaults to 'block'"
required: false
type: string
default: "block"
is-release-branch:
description: "If this is a release branch (e.g., main)"
type: boolean
Expand All @@ -12,10 +17,6 @@ on:
type: boolean
required: false
default: false
secrets:
GITHUB_ACCESS_TOKEN:
description: "GitHub token"
required: true
outputs:
should-release:
description: "Boolean indicating if release should happen"
Expand All @@ -31,10 +32,18 @@ jobs:
outputs:
should-release: ${{ steps.set-output.outputs.should-release }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
api.github.com:443

- name: Determine release eligibility
id: set-output
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
SHA: ${{ github.sha }}
IS_RELEASE_BRANCH: ${{ inputs.is-release-branch }}
Expand All @@ -53,20 +62,28 @@ jobs:
COMMITS=$(gh api repos/$REPO/compare/$LAST_TAG...$SHA --jq '.commits[].commit.message')
else
# No previous tag, consider all commits
COMMITS=$(gh api repos/$REPO/commits?sha=$SHA --jq '.[].commit.message')
COMMITS=$(gh api "repos/$REPO/commits?sha=$SHA" --paginate --jq '.[].commit.message')
fi

# Extract PR numbers
PRS=$(echo "$COMMITS" | grep -oE '#[0-9]+' | sort -u | tr -d '#')

# Check labels of each PR
for pr in $PRS; do
LABELS=$(gh api repos/$REPO/pulls/$pr --jq '.labels[].name')
if ! echo "$LABELS" | grep -q "no-release"; then
if [ -z "$PRS" ]; then
# Commits exist but no PR references found - release by default
if [ -n "$COMMITS" ]; then
should_release=true
break
fi
done
else
# Check labels of each PR
for pr in $PRS; do
LABELS=$(gh api repos/$REPO/pulls/$pr --jq '.labels[].name')
if ! echo "$LABELS" | grep -q "no-release"; then
should_release=true
break
fi
done
fi
fi

echo "should-release=$should_release" >> $GITHUB_OUTPUT
echo "should-release=$should_release"
21 changes: 12 additions & 9 deletions .github/workflows/_dependabot-auto-approve-and-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ on:
pr-url:
required: true
type: string
secrets:
GITHUB_ACCESS_TOKEN:
description: "(ie: GITHUB_TOKEN) GitHub token"
required: true

jobs:
approve:
runs-on: ubuntu-latest
Expand All @@ -28,7 +23,11 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
api.github.com:443
github.com:443

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -40,19 +39,19 @@ jobs:
- name: Check for merge conflicts
uses: sv-tools/block-merge-conflicts@911859e7a913f086e9f89db5117e0942690bd64e # v2.0.0
with:
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Approve a PR if not already approved
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
run: |
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status`
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
then gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "${PR_URL}"
then gh pr review --approve "$PR_URL"
else echo "PR already approved, skipping additional approvals to minimize emails/notification noise.";
fi
env:
PR_URL: ${{ inputs.pr-url}}
GITHUB_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

merge:
runs-on: ubuntu-latest
Expand All @@ -64,7 +63,11 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
api.github.com:443
github.com:443

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -74,4 +77,4 @@ jobs:
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ inputs.pr-url}}
GITHUB_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/_dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: dependency-review

on:
workflow_call:
inputs:
harden-runner-policy:
description: "The egress policy for the Harden Runner step. Defaults to 'block'"
required: false
type: string
default: "block"

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@6c3c2f2c1c457b00c10c4848d6f5491db3b629df # v2.18.0
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
api.deps.dev:443
api.github.com:443
api.securityscorecards.dev:443
github.com:443

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Run dependency review
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
7 changes: 7 additions & 0 deletions .github/workflows/_dotnet-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}

- name: Print raw inputs
run: |
echo "Raw input: dotnet-version-matrix='${{ inputs.dotnet-version-matrix }}'"
Expand Down Expand Up @@ -90,6 +96,7 @@ jobs:
api.nuget.org:443
auth.docker.io:443
builds.dotnet.microsoft.com:443
dotnetcli.azureedge.net:443
cognito-identity.us-east-1.amazonaws.com:443
crl.sectigo.com:443
crl3.digicert.com:80
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/_dotnet-build-test-pack-publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ on:
required: false
default: false
secrets:
GITHUB_ACCESS_TOKEN:
description: "(ie: GITHUB_TOKEN) GitHub token"
required: true
NUGET_API_KEY:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
Expand All @@ -62,7 +59,8 @@ on:
required: false

permissions:
contents: read
contents: write
packages: write
pull-requests: read

jobs:
Expand All @@ -78,10 +76,10 @@ jobs:
contents: read
pull-requests: read
with:
harden-runner-policy: ${{ inputs.harden-runner-policy }}
is-release-branch: ${{ inputs.is-release-branch }}
force-release: ${{ inputs.force-release }}
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
secrets: inherit

build-and-test:
uses: ./.github/workflows/_dotnet-build-and-test.yml
Expand All @@ -92,8 +90,8 @@ jobs:
dotnet-version-matrix: ${{ inputs.dotnet-version-matrix }}
dotnet-version: ${{ inputs.dotnet-version }}
codecov-slug: ${{ inputs.codecov-slug }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
codecov-flag: ${{ inputs.codecov-flag }}
secrets: inherit

pack:
needs:
Expand Down Expand Up @@ -126,9 +124,7 @@ jobs:
num-github-prerelease-packages-to-keep: ${{ inputs.num-github-prerelease-packages-to-keep }}
upload-to-github: ${{ inputs.is-release-branch == false || needs.check-release-eligibility.outputs.should-release == 'false' }}
upload-to-nuget: ${{ inputs.is-release-branch == true && needs.check-release-eligibility.outputs.should-release == 'true' }}
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
secrets: inherit

release:
needs:
Expand All @@ -142,5 +138,4 @@ jobs:
with:
harden-runner-policy: ${{ inputs.harden-runner-policy }}
version: ${{ needs.get-version.outputs.version }}
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_ACCESS_TOKEN }}
secrets: inherit
19 changes: 13 additions & 6 deletions .github/workflows/_dotnet-publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ on:
required: false
default: false
secrets:
GITHUB_ACCESS_TOKEN:
description: "(ie: GITHUB_TOKEN) GitHub token to upload package to GitHub Package Registry. Required if upload-to-github is true"
required: false
NUGET_API_KEY:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
Expand Down Expand Up @@ -95,7 +92,7 @@ jobs:
dotnet nuget push build-packages/*.nupkg
--skip-duplicate
--source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
--api-key ${{ secrets.GITHUB_ACCESS_TOKEN }}
--api-key ${{ secrets.GITHUB_TOKEN }}

- name: Publish symbol package(s) to GitHub Package Registry
if: ${{ inputs.upload-to-github }}
Expand All @@ -104,7 +101,7 @@ jobs:
dotnet nuget push build-packages/*.snupkg
--skip-duplicate
--source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
--api-key ${{ secrets.GITHUB_ACCESS_TOKEN }}
--api-key ${{ secrets.GITHUB_TOKEN }}

- name: Publish nuget and symbols package(s) to NuGet.org
if: ${{ inputs.upload-to-nuget }}
Expand All @@ -116,6 +113,7 @@ jobs:
--api-key ${{ secrets.NUGET_API_KEY }}

discover-packages:
if: inputs.upload-to-github
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
Expand Down Expand Up @@ -162,13 +160,22 @@ jobs:
echo "$json"

cleanup:
if: inputs.upload-to-github
needs: discover-packages
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.discover-packages.outputs.matrix) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
api.github.com:443

- name: Delete old versions for ${{ matrix.package }}
uses: actions/delete-package-versions@v5
uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5
with:
package-name: ${{ matrix.package }}
package-type: nuget
Expand Down
Loading
Loading