Repository navigation
244 lines (215 loc) · 11 KB
/
Copy pathpublish.yml
File metadata and controls
244 lines (215 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: Publish to npm
# Source-of-truth model:
# The version comes from the root `package.json` `version` field. Maintainers
# advance it via `pnpm bump-minor`. This workflow can never publish a version
# other than what is committed at HEAD.
#
# Trigger model:
# - push to `main` with the root `version` unchanged → publish `<base>-dev.N`
# under dist-tag `dev`.
# - push to `main` with the root `version` changed → publish `<base>` under
# dist-tag `next` and create a GitHub Release. This is how a merged
# release-bump PR publishes a release. It never moves `latest`: a
# maintainer promotes the release to `latest` later
# (docs/oss/versioning.md). The same run then publishes `<base>-dev.N`
# under `dev`, so every push to `main` — release or not — leaves the `dev`
# dist-tag on a build of that commit. When releases skipped the dev
# publish, `dev` sat on the previous base until the next routine push.
# - workflow_dispatch → publish `<base>` under the chosen dist-tag (default
# `next`; `latest` and `dev` are refused); also the dry-run path. A run under
# `next` re-publishes a release whose publish failed, and counts as a release.
on:
push:
branches: [main]
tags: ["!**"]
workflow_dispatch:
inputs:
dist-tag:
description: "npm dist-tag: next re-publishes a release whose publish failed (latest and dev are refused)"
required: true
default: "next"
type: string
dry-run:
description: "Dry-run only (build + pack + gate, no npm publish, no GitHub Release)."
required: false
default: true
type: boolean
concurrency:
group: npm-publish
cancel-in-progress: false
jobs:
publish:
name: Publish packages to npm
runs-on: ubuntu-latest
# Only `main` may produce a real publish. A dry-run dispatch is permitted from
# any branch so maintainers can validate the pipeline (build + pack + gate +
# `publish --dry-run`) before merging changes that touch publishing. The
# dry-run path performs no registry writes and skips the GitHub Release step.
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 and git tags
id-token: write # Required for npm OIDC Trusted Publishing
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# determine-version.ts compares the root `package.json` version at
# `github.event.before` to HEAD to decide dev vs release; a multi-commit
# push can place `before` arbitrarily far back, so fetch full history.
fetch-depth: 0
- uses: ./.github/actions/setup
- name: Configure npm
run: pnpm config set registry https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Determine version
id: version
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
INPUT_DIST_TAG: ${{ github.event.inputs.dist-tag }}
# `before` is the ref `main` pointed at before this push;
# determine-version.ts reads root package.json there to detect release
# bumps. Empty for workflow_dispatch, which the script also handles.
PUSH_BEFORE_SHA: ${{ github.event.before }}
run: node scripts/determine-version.ts
- name: Set package versions
run: node scripts/set-version.ts "${{ steps.version.outputs.version }}"
- name: Build packages
run: pnpm build
# Publish-time gate: packs every publishable package and fails if a
# resolved package.json would carry a workspace:/catalog: specifier or a
# non-exact internal pin into the registry.
- name: Check publish dependency specifiers
run: pnpm check:publish-deps
# The remaining publish-blocking invariants, against the exact artifacts
# this run would upload (the build step above built everything):
# engine-once — the engine is an exact peer of the CLI package, external
# in its tarball, and absent from the library.
- name: Check the cli-engine pin and externality
run: pnpm check:cli-engine-pin
# The agent skill ships inside the @prisma/composer tarball and must
# carry the version stamp this run just wrote.
- name: Check the skill ships in the tarball
run: pnpm check:skill-packaging
# Lazy executor boundary — nothing statically reachable from the family,
# bin, or testing entrypoints imports alchemy or effect.
- name: Check the family and testing static graphs
run: pnpm check:family-static-graph
# Every source map the build wrote names our TypeScript, and auth/testing
# carries no copy of the Prisma ORM.
- name: Check the published source maps
run: pnpm check:published-source-maps
# npm-tree survival — a real `npm install` of the packed tarballs
# resolves one pinned effect, and the CLI starts (and fails loudly in an
# adversarial tree).
- name: Check npm resolves a single pinned effect
run: pnpm check:npm-effect-resolution
# Dry-run path: exercises the full pipeline (pack, dependency rewriting)
# without touching the registry. Use from any branch via workflow_dispatch.
- name: Publish packages (dry-run)
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'true' }}
run: node scripts/publish-packages.mjs --tag "${{ steps.version.outputs.tag }}" --dry-run
# NODE_AUTH_TOKEN is intentionally NOT set. npm detects the OIDC environment
# (id-token: write) and authenticates via Trusted Publishing automatically;
# setting NODE_AUTH_TOKEN to any value — even empty — would block OIDC.
# NPM_CONFIG_PROVENANCE enables provenance attestations (requires a public repo).
- name: Publish packages
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run != 'true' }}
env:
NPM_CONFIG_PROVENANCE: "true"
run: node scripts/publish-packages.mjs --tag "${{ steps.version.outputs.tag }}"
# Lightweight git tag for publishes that are not releases (a manual run
# under a tag such as `beta`). Releases get their tag from
# `gh release create` below. Idempotent: skip if v$VERSION exists.
- name: Create lightweight git tag for publishes that are not releases
if: ${{ steps.version.outputs.release != 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run != 'true') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists; skipping"
else
gh api "repos/$GITHUB_REPOSITORY/git/refs" \
-X POST \
-f ref="refs/tags/v$VERSION" \
-f "sha=$GITHUB_SHA"
fi
# Emit a GitHub Release for releases: a release-bump push, or a manual
# run under `next`. Notes are auto-generated from the commits/PRs since
# the previous tag. `--latest=false`: GitHub marks it its latest release
# when promote.yml moves npm `latest`.
# Idempotent on rerun: edit an existing Release rather than re-create it.
- name: Create GitHub Release
if: ${{ steps.version.outputs.release == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run != 'true') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if gh release view "v$VERSION" >/dev/null 2>&1; then
gh release edit "v$VERSION" \
--target "$GITHUB_SHA" \
--title "v$VERSION"
else
gh release create "v$VERSION" \
--target "$GITHUB_SHA" \
--title "v$VERSION" \
--latest=false \
--generate-notes
fi
# Tell prisma-cli a release shipped so its update-product-versions
# workflow can open the repin PR now instead of at its daily run
# (prisma-cli docs/oss/release-automation.md). Releases only: the
# receiver reads each product's `next` tag first, so it finds this
# release; a dev publish would be a no-op there. Never fails the publish.
- name: Notify prisma-cli
if: ${{ steps.version.outputs.release == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run != 'true') }}
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "DEPLOY_GITHUB_TOKEN is not configured; skipping (the daily run in prisma-cli covers this)."
exit 0
fi
gh api repos/prisma/prisma-cli/dispatches \
-f event_type=product-published \
-f 'client_payload[package]=@prisma/composer-cli' \
-f "client_payload[version]=$VERSION"
# --- Dev follow-up, release pushes only (devVersion is empty otherwise).
# The release steps above already ran the full check battery against this
# commit; only the version stamp changes here, so the follow-up re-runs
# just the version-sensitive checks (publish-deps and the skill stamp)
# before publishing.
- name: Set package versions (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
run: node scripts/set-version.ts "${{ steps.version.outputs.devVersion }}"
- name: Build packages (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
run: pnpm build
- name: Check publish dependency specifiers (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
run: pnpm check:publish-deps
- name: Check the skill ships in the tarball (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
run: pnpm check:skill-packaging
- name: Publish packages (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
env:
NPM_CONFIG_PROVENANCE: "true"
run: node scripts/publish-packages.mjs --tag dev
- name: Create lightweight git tag (dev follow-up)
if: ${{ steps.version.outputs.devVersion != '' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.devVersion }}
run: |
if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists; skipping"
else
gh api "repos/$GITHUB_REPOSITORY/git/refs" \
-X POST \
-f ref="refs/tags/v$VERSION" \
-f "sha=$GITHUB_SHA"
fi