Port of [#18887](#18887) to
`3.x`. The first commit is the cherry-pick. The second commit has the
`3.x` differences:
- Runners stay on `ubuntu-24.04`, like the rest of `3.x`. Will update
`3.x` to 26 in a separate PR.
- Adds `writeStepSummary.ts`, which `3.x` does not have.
[#18981](#18981) adds the same
file with identical content, so the second PR to merge gets no conflict.
- Adds `.github/scripts/**/*.spec.mjs` to the vitest `unit` project.
Without it, the attach script spec does not run on `3.x`.
- `SECURITY.md` describes v3 releases.
Each stable v3 draft GitHub Release now gets one
`payload-sboms-<version>.zip`. It holds a CycloneDX 1.6 and an SPDX 2.3
SBOM (software bill of materials: a machine-readable dependency list)
for every published package, plus a `SHA256SUMS` file. A push to `3.x`
checks that generation still works.
```diff
.github/
├── scripts/
+│ └── sbom/attach-sboms.mjs # uploads the zip to the draft release
└── workflows/
├── main.yml # + sbom job, push to 3.x only
└── publish-release.yml # + generate-sboms, attach-sboms jobs
tools/releaser/src/
+├── release-sbom.ts # pnpm release-sbom --out-dir <dir>
+└── lib/sbom/ # formats, checks, SPDX supplier, zip bundle
SECURITY.md # + SBOM section
```
Customers run security and compliance audits on the Payload packages
they install. They need one SBOM per package, downloadable from the
GitHub Release.
```text
https://github.com/payloadcms/payload/releases/download/v3.93.0/payload-sboms-3.93.0.zip
payload-sboms-3.93.0/
├── payload-3.93.0.cdx.json
├── payload-3.93.0.spdx.json
├── payloadcms-db-postgres-3.93.0.cdx.json
├── ...
└── SHA256SUMS
pnpm release-sbom --out-dir /tmp/sboms # same generator, locally
```
## Changes
- **SBOM generator (`pnpm release-sbom`)**
- Runs `pnpm sbom --split` once per format over the publish list. Flags
are `--prod --exclude-peers --sbom-type library`.
- Fails when the output dir is not empty or the file set differs from
the expected names. Stale files cannot ship.
- Checks each file for spec version, root package name, a license on
every component, and every direct dependency.
- Sets the SPDX root supplier to `Organization: Payload CMS, LLC`. pnpm
ignores `--sbom-supplier` for SPDX.
- Writes `SHA256SUMS` into `payload-sboms-<version>/` and zips that
folder.
- **Release workflow**
- `generate-sboms` runs after `publish`. It installs, generates, and
uploads the zip as an artifact.
- `attach-sboms` uploads the zip to the draft release with the label
`SBOMs`.
- On a rerun, the attach script deletes the existing zip asset before it
uploads.
- The draft can be published before `attach-sboms` finishes. The script
uploads to a draft or a published release.
- **Main push check**
- A new `sbom` job runs the generator on push to `3.x` when lockfile,
manifests, pnpm version, generator files, or `main.yml` change. It is
not part of `all-green`.
- **Docs**
- `SECURITY.md` documents the zip URL, the folder layout, what the SBOM
covers, and checksum verification.
## Design Decisions
- SBOMs describe what Payload built and tested each package with. They
come from the repo lockfile in the real workspace. A fresh consumer
resolve in a temp dir was rejected. `workspace:*` deps fail to install
there. Customers can scan their own lockfile to see what their install
resolves to.
- Direct peer dependencies are excluded with `--exclude-peers`. The
consumer's project provides `next`, `react`, and `payload`. Peers of
transitive dependencies can still appear.
- The release gets one zip instead of one asset per SBOM. Separate files
would put dozens of assets on every release page. The cost is no
per-package download URL.
- Generation and upload are two jobs after `publish`. `publish` is
unchanged, so an SBOM failure never blocks npm. "Re-run failed jobs"
retries only the SBOM jobs.
- `generate-sboms` runs third-party install scripts with `contents:
read`. `attach-sboms` holds `contents: write` and runs no installed
code. It checks out only `.github/scripts/sbom` and runs it through
`actions/github-script`.
- The attach job derives the zip name from the release tag and uses a
fixed label. Nothing in the artifact chooses which file reaches the
write token.
- The attach script lists releases and matches `tag_name`, so it finds a
draft or a published release. `GET /releases/tags/{tag}` cannot be used,
because it returns 404 for drafts.
- CycloneDX is pinned to 1.6. Snyk, FOSSA, and older Dependency-Track
reject 1.7, the pnpm default. SPDX 2.3 covers procurement that asks for
SPDX by name.
## Overall Flow
```diff
tag v3.*.* pushed
publish (environment: release, id-token: write)
pnpm release-ci: build, npm publish, create draft release
+ generate-sboms (contents: read)
+ pnpm install
+ pnpm release-sbom: generate, check, SHA256SUMS, zip
+ upload artifact (zip)
+ attach-sboms (contents: write, no install)
+ download artifact
+ find release by tag_name
+ delete existing zip asset, upload zip with its label
```
## References / Links
- [pnpm sbom](https://pnpm.io/cli/sbom): generation flags and `--split`
output names
- [About
releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases):
asset limits and naming
- [actions/github-script](https://github.com/actions/github-script):
running a repo script with the job token
## Verify After Merge
Local runs covered generation, the checks, the zip, and `SHA256SUMS`.
The items below run only in CI.
- **Merge of this PR (first push to `3.x`)**
- The merge touches generator files. The `needs_sbom` filter should
start the `sbom` job.
- The generator runs on the CI runner after the shared setup action.
- **First v3 release tag**
- `generate-sboms` installs on a tag ref. The pnpm cache from `3.x`
should restore.
- The zip passes from `generate-sboms` to `attach-sboms` as an artifact.
- `attach-sboms` checks out only `.github/scripts/sbom` and imports the
script through `actions/github-script`.
- `GITHUB_TOKEN` finds the draft that the App token created and uploads
to it.
- The release has one asset, `payload-sboms-<version>.zip`, with the
label `SBOMs`.
- A rerun of `attach-sboms` replaces the zip. The release still has one
asset.
- **If `attach-sboms` fails**
- npm and the release are not affected. Download the artifact and run
`gh release upload`.
🤖 Written with AI
Ports #18796 from main to 3.x. A
release-bumpdry run now shows the release notes that the real release will get. It also removes the localpnpm releasefallback.v3.92.0 was the first 3.x release from CI. Its dry run showed only the git commands. The notes first appeared in the draft GitHub release, after the npm publish.
Changes
base..HEAD, labeled with the next version.$GITHUB_STEP_SUMMARY(the Markdown job summary on the run page).generateReleaseNotestakes an optionalreleaseTag. It sets the version in the heading, compare link, and release URL.chore(release): vXcommit filter applies to every range. Before, it applied to tag ranges only.release-bumpandrelease-cilistv3.*tags through onelistReleaseTagshelper.release.ts,publishLocalRelease, bothreleasescripts, and thepromptsdependencies.[skip ci]check frompublish-release. The check only stopped a second publish after a local release.Design Decisions
Release tagsruleset lets only the release bot createv3.*tags. A localpnpm releasecannot push its tag. Its printed resume steps also tell the maintainer to push one.release-ci. Only the heading date and commits merged after the dry run can differ.Overall Flow
References / Links
$GITHUB_STEP_SUMMARYrenders Markdown on the run page.🤖 Written with AI