Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
b0e26b0
ci(publish): a release publishes under rc and never moves latest
wmadden-electric Dec 2, 2026
a394cd9
ci(promote): move latest to a checked release with promote.yml
wmadden-electric Dec 2, 2026
70d5f9d
fix(release): follow the newest of rc and latest; correct the remaini…
wmadden-electric Dec 2, 2026
10587ef
ci(release): GitHub marks a release Latest only when promote.yml move…
wmadden-electric Dec 2, 2026
ce06054
fix(promote): check the promotion before moving latest; document the …
wmadden-electric Dec 2, 2026
863c820
fix(release): stage releases under next; promote checks before npm ch…
wmadden-electric Dec 2, 2026
175a869
fix(promote): allow older pins only in a rollback; read latest uncached
wmadden-electric Dec 2, 2026
dd07221
docs(release): correct two stale statements about next and candidate …
wmadden-electric Dec 2, 2026
f490ed9
ci(promote): follow the ORM's promote.yml: plan from the release tag,…
wmadden-electric Dec 2, 2026
4babe2c
test(promote): avoid template-like strings that the linter flags
wmadden-electric Dec 2, 2026
5723e71
fix(promote): a repeat run of a finished rollback passes; doc says th…
wmadden-electric Dec 2, 2026
509aa08
fix(promote): refuse range pins, read pins from both packages, check …
wmadden-electric Dec 2, 2026
6c22bda
fix(promote): a dry run cannot replace a waiting real promotion
wmadden-electric Dec 2, 2026
44b3849
docs(versioning): the promotion check reads pins from both CLI packages
wmadden-electric Dec 2, 2026
a1984f9
fix(promote): only a real run from main joins the promotion's concurr…
wmadden-electric Dec 2, 2026
792591d
test(promote): match the concurrency group for runs off main
wmadden-electric Dec 2, 2026
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
216 changes: 216 additions & 0 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Promote a release to latest

# A release is published under the `next` dist-tag (publish.yml); a bare install
# resolves `latest`. This workflow moves `latest` for `prisma` and `@prisma/cli`
# to a published release, by hand, once the Prisma ORM, Composer and CLI
# versions that work together are all released and checked, and refuses while
# the ORM and Composer versions the release pins are not `latest` yet. See
# docs/oss/versioning.md. The same shape as prisma/orm's promote.yml.
#
# Three jobs, so that the npm token meets no code from the repository and no
# repository write access:
# - check: no token, read-only. Runs this workflow's own scripts on the
# release's tag, checked out as data only, and outputs what to move. A dry
# run ends here, from any branch.
# - promote: main only, not a dry run. Holds the token from the npm-promote
# environment, checks out nothing, and has no repository permissions.
# - mark-latest: marks the GitHub Release as Latest, for a stable release.

on:
workflow_dispatch:
inputs:
version:
description: "Release version to promote, such as 8.0.0-rc.37"
required: true
type: string
dry-run:
description: "Dry run: check the release and print the moves, without changing any tag"
required: false
default: true
type: boolean
allow-downgrade:
description: "Allow moving latest back to an older release (a rollback)"
required: false
default: false
type: boolean

# A group keeps only one pending run, and a newer one replaces it. So any run
# that is not a real promotion from main (a dry run, or a run from another
# branch, which fails its input check) gets a group of its own, and cannot
# replace a real promotion waiting behind a running one.
concurrency:
group: ${{ (inputs.dry-run || github.ref != 'refs/heads/main') && format('npm-promote-dry-run-{0}', github.run_id) || 'npm-promote' }}
cancel-in-progress: false

permissions: {}

jobs:
check:
name: Check the release
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
plan: ${{ steps.plan.outputs.plan }}

steps:
- name: Check the inputs
env:
VERSION: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry-run }}
run: |
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'; then
echo "::error::\"$VERSION\" is not a release version, such as 8.0.0-rc.37 or 8.1.0."
exit 1
fi
if [ "$DRY_RUN" != "true" ] && [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "::error::A real promotion runs only from main. Run from $GITHUB_REF as a dry run, or dispatch from main."
exit 1
fi

- name: Checkout this workflow's ref
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false

# Data only: nothing in this folder is run.
- name: Checkout the release's tag as data
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: v${{ inputs.version }}
path: release-data
persist-credentials: false

- name: Check the release's tag is on main
env:
VERSION: ${{ inputs.version }}
run: |
tagged="$(git rev-parse "v$VERSION^{commit}")"
if [ "$(git -C release-data rev-parse HEAD)" != "$tagged" ]; then
echo "::error::The two checkouts of v$VERSION differ; the tag moved during the run."
exit 1
fi
if ! git merge-base --is-ancestor "$tagged" origin/main; then
echo "::error::v$VERSION points at $tagged, which is not on main. Only a release published from main can be promoted."
exit 1
fi

# Checked before npm changes, so marking a stable release Latest cannot fail
# after `latest` has moved. A tag can exist with no release.
- name: Check a stable release's GitHub Release exists
if: ${{ !contains(inputs.version, '-') }}
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
if ! gh release view "v$VERSION" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft == false' | grep -qx true; then
echo "::error::GitHub Release v$VERSION is missing or still a draft. Publish it first; nothing was changed."
exit 1
fi

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version

- name: Plan the promotion
id: plan
env:
VERSION: ${{ inputs.version }}
ALLOW_DOWNGRADE: ${{ inputs.allow-downgrade }}
run: |
flags=()
if [ "$ALLOW_DOWNGRADE" = "true" ]; then flags+=(--allow-downgrade); fi
node scripts/promote-release.ts "$VERSION" --release-root release-data --plan-out "$RUNNER_TEMP/plan.json" "${flags[@]}"
echo "plan=$(jq -c . "$RUNNER_TEMP/plan.json")" >> "$GITHUB_OUTPUT"

promote:
name: Move latest to the release
needs: check
if: ${{ github.ref == 'refs/heads/main' && !inputs.dry-run }}
runs-on: ubuntu-latest
environment: npm-promote
permissions: {}
outputs:
version: ${{ steps.move.outputs.version }}

steps:
- name: Check the npm token
env:
NPM_TOKEN: ${{ secrets.NPM_PROMOTE_TOKEN }}
run: |
if [ -z "$NPM_TOKEN" ]; then
echo "::error::The npm-promote environment has no NPM_PROMOTE_TOKEN secret. Create a short-lived npm token, add it to that environment as NPM_PROMOTE_TOKEN, run again, then delete the secret and revoke the token. See docs/oss/versioning.md."
exit 1
fi
echo "::add-mask::$NPM_TOKEN"

# Runs no code from the repository: the plan comes from the check job, and
# each name and version in it is checked before use. The token reaches npm
# only through this step's environment, by a config file outside any
# checkout that refers to NODE_AUTH_TOKEN rather than holding it.
- name: Move latest
id: move
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PROMOTE_TOKEN }}
PLAN: ${{ needs.check.outputs.plan }}
run: |
set -euo pipefail
version_re='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
name_re='^(prisma|@prisma/cli)$'
release="$(jq -r '.version' <<<"$PLAN")"
entries="$(jq -r '.packages[] | "\(.name) \(.version)"' <<<"$PLAN")"
[[ $release =~ $version_re ]] || { echo "::error::The plan's version \"$release\" is not a version."; exit 1; }
[ -n "$entries" ] || { echo "::error::The plan lists no package."; exit 1; }
while read -r name version <&3; do
[[ $name =~ $name_re ]] || { echo "::error::The plan names \"$name\", which is not one of ours."; exit 1; }
[[ $version =~ $version_re ]] || { echo "::error::The plan gives $name \"$version\", which is not a version."; exit 1; }
done 3<<<"$entries"

npmrc="$RUNNER_TEMP/promote.npmrc"
printf '%s\n' 'registry=https://registry.npmjs.org/' "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" > "$npmrc"
export NPM_CONFIG_USERCONFIG="$npmrc"

while read -r name version <&3; do
if [ "$(npm view "$name@$version" version 2>/dev/null || true)" != "$version" ]; then
echo "::error::$name@$version is not on the registry. Nothing moved."
exit 1
fi
done 3<<<"$entries"

moved=()
while read -r name version <&3; do
if [ "$(npm view "$name" dist-tags.latest)" = "$version" ]; then
echo "$name: latest is already $version"
continue
fi
if npm dist-tag add "$name@$version" latest || npm dist-tag add "$name@$version" latest; then
moved+=("$name")
echo "$name: latest moved to $version"
else
echo "::error::Moving latest failed for $name@$version. Moved in this run: ${moved[*]:-none}. Run the workflow again to move the rest; packages already moved are left alone."
exit 1
fi
done 3<<<"$entries"
echo "version=$release" >> "$GITHUB_OUTPUT"

mark-latest:
name: Mark the GitHub Release as Latest
needs: promote
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# publish.yml creates the GitHub Release without the Latest mark. GitHub
# does not let a pre-release be Latest, so a release candidate stays as it is.
- name: Mark the GitHub Release as Latest
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.promote.outputs.version }}
run: |
if [ "$(gh release view "v$VERSION" --repo "$GITHUB_REPOSITORY" --json isPrerelease --jq .isPrerelease)" = "true" ]; then
echo "v$VERSION is a pre-release, which GitHub does not let be Latest; leaving it as it is."
else
gh release edit "v$VERSION" --repo "$GITHUB_REPOSITORY" --latest
fi
10 changes: 6 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
workflow_dispatch:
inputs:
dist-tag:
description: "npm dist-tag. Empty = latest, the canonical tag for every release since the 2026-08-25 cutover. Pass another tag (e.g. beta) for a hand-cut preview."
description: "npm dist-tag. Empty = next, the tag every release publishes under. latest is refused: promote.yml moves it. Pass another tag (e.g. beta) for a hand-cut preview."
required: false
default: ""
type: string
Expand All @@ -38,7 +38,7 @@ jobs:
# from any branch.
if: ${{ github.ref == 'refs/heads/main' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'true') }}
permissions:
contents: write # Required to create the GitHub Release + tag for latest publishes
contents: write # Required to create the GitHub Release + tag for releases
id-token: write # Required for npm OIDC Trusted Publishing

steps:
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
env:
NPM_CONFIG_PROVENANCE: "true"
DIST_TAG: ${{ steps.version.outputs.releaseTag }}
run: bash scripts/publish-packages.sh "$DIST_TAG" @prisma/cli-engine @prisma/cli prisma
run: bash scripts/publish-packages.sh "$DIST_TAG" @prisma/cli prisma

- name: Verify the release resolves
if: ${{ steps.version.outputs.release == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run != 'true') }}
Expand Down Expand Up @@ -224,6 +224,7 @@ jobs:
-f name="v$VERSION" \
-F draft=true \
-F prerelease=$PRERELEASE \
-f make_latest=false \
-F generate_release_notes=true \
--jq .id)
if [ -z "$release_id" ]; then
Expand All @@ -237,6 +238,7 @@ jobs:
"https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id/assets?name=$(basename "$tarball")" \
--input "$tarball" >/dev/null
done
# promote.yml marks it Latest when it moves npm's latest.
gh api -X PATCH "repos/$GITHUB_REPOSITORY/releases/$release_id" \
-F draft=false >/dev/null
-F draft=false -f make_latest=false >/dev/null
echo "Published release v$VERSION with $(find artifacts/tarballs -name '*.tgz' | wc -l | tr -d ' ') asset(s)."
2 changes: 1 addition & 1 deletion .github/workflows/update-product-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH"
PR_URL=$(gh pr create \
--title "$TITLE" \
--body "Opened automatically by update-product-versions.yml, following the products' release dist-tags ($SUMMARY). Merging releases \`prisma@$VERSION\` under \`latest\`; the checks on this pull request are what stand between a product release and that CLI release." \
--body "Opened automatically by update-product-versions.yml, following the products' release dist-tags ($SUMMARY). Merging publishes \`prisma@$VERSION\` under \`next\`, and \`latest\` moves when a maintainer runs promote.yml; the checks on this pull request are what stand between a product release and that CLI release." \
--base main --head "$BRANCH")
gh pr merge --auto --squash "$PR_URL"
echo "Opened $PR_URL with auto-merge armed."
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ The CLI must preserve the unified command model:

Releases use `@prisma/cli` (exposing the `prisma-cli` binary) plus its
dependency `@prisma/cli-engine`, versioned in lockstep from the root
`package.json` on the Prisma 8 RC line (`8.0.0-rc.N`). The `latest` dist-tag moves
when a version-bump PR merges; see `docs/oss/versioning.md`.
`package.json` on the Prisma 8 RC line (`8.0.0-rc.N`). A merged version-bump PR
publishes under the `next` dist-tag; `latest` moves when a maintainer promotes the
release with `promote.yml`; see `docs/oss/versioning.md`.

The `dev` dist-tag points at the latest successful `main` build, published as
`<base>-dev.N`. Commit traceability comes from npm
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ branches, services, service versions, environment variables, and the Prisma ORM
schema and migration workflow.

The 8.0.0 release candidates publish as `prisma` (binary `prisma`) and
`@prisma/cli` (binary `prisma-cli`) on the `latest` dist-tag.
`@prisma/cli` (binary `prisma-cli`) on the `next` dist-tag, and move to `latest`
once checked.

## Install

Expand Down Expand Up @@ -135,7 +136,8 @@ lockstep) is the release source of truth. The workflow publishes

Release channels:

- `latest`: releases on the Prisma 8 RC line (`8.0.0-rc.N`). A merged PR that bumps the root version (via `pnpm bump-version`) publishes automatically: a maintainer's release PR, or the version-follow PR a product release opens; `workflow_dispatch` is the manual escape hatch and the dry-run path.
- `next`: every release, as soon as it publishes (today, the Prisma 8 RC line, `8.0.0-rc.N`). A merged PR that bumps the root version (via `pnpm bump-version`) publishes automatically: a maintainer's release PR, or the version-follow PR a product release opens; `workflow_dispatch` is the manual escape hatch and the dry-run path.
- `latest`: the release a maintainer has checked and promoted. See [versioning](docs/oss/versioning.md).
- `dev`: latest successful `main` build. Every push to `main` that does not
change the root version publishes `<base>-dev.N` under the `dev` dist-tag.
Commit traceability comes from npm provenance and the GitHub Actions run.
Expand Down
Loading
Loading