Commit bb508ea
authored
ci: require --tag for releases, route v3 template PRs to 3.x (#16360)
# Overview
Main-side tooling for the v4 beta phase. Harden `pnpm release` against
accidentally publishing to `latest`, route the post-release templates
workflow by release major so v3 patches (published from `3.x`) produce
the right PR on the right branch, and close script-injection patterns in
that workflow.
Companion to the pending `3.x` cutover. No functional changes to Payload
itself.
## Key Changes
- **`tools/releaser/src/release.ts` — require `--tag`; disallow
`latest`**
- Abort when `--tag` is missing. Previously an omitted tag flowed into
`pnpm publish --tag undefined` and published to a literal `undefined`
dist-tag.
- Abort when `--tag latest` is passed. During the v4 beta phase, stable
v4 must publish to `beta` so it cannot displace v3 on `latest`.
- Both guards print a pointer to remove them at Phase 2 when v4 goes
stable.
- **`.github/workflows/post-release-templates.yml` — route by release
tag**
- Compute `target_branch` from the release tag: `v3.*` → `3.x`,
everything else → `main`.
- `update_templates` checks out `target_branch`, so templates are
regenerated from the source that corresponds to the released major.
- PR `base` now targets `target_branch` instead of hardcoded `main`. A
v3 patch produces a templates PR against `3.x`; a v4 release produces
one against `main`.
- `workflow_dispatch` still works; it uses `git describe` to pick the
latest non-v2 tag and routes the same way.
- **`.github/workflows/post-release-templates.yml` — harden release-tag
handling**
- Pass `github.event.release.tag_name` through `env:` rather than
interpolating `${{ … }}` directly into `run:` blocks (closes the classic
GHA script-injection pattern).
- Validate the tag against a semver shape before it fans out into step
outputs and downstream steps; the job aborts on a malformed tag instead
of letting shell-metacharacter content reach the branch name, PR title,
or PR body.
- Replace the remaining inline `${{ … release_tag }}` shell
interpolations with `$RELEASE_TAG` from `env:`.
## Design Decisions
- **Disallow `latest` rather than default to `beta`.** Explicit caller
intent; Phase 2 revert is a two-line deletion. No branch-detection or
magic defaults inside the releaser.
- **Route rather than skip v3 in post-release-templates.** An earlier
iteration skipped v3 events entirely. Routing preserves template
regeneration for 3.x patches, which is the behavior the 3.x maintenance
line needs.
- **Workflow file stays on `main` only.** `release: published` events
run the workflow from the repo default branch regardless, so the file
does not need to exist on `3.x`. It only needs to check out `3.x` when
handling a v3 release.
- **Validate tag shape at the boundary, not everywhere downstream.** A
single semver regex at the `determine_tag` step means all downstream
outputs, branch names, and PR inputs inherit a safe character set
without repeating validation.
- **No changes to `post-release.yml`, `publish-prerelease.yml`,
`main.yml`, `templates.ts`, or docs.** The release-commenter's existing
`tag-filter: 'v\d'` already partitions v3/v4. Nightly canary cron is
disabled in a separate prior commit and is expected to be re-enabled
when v4 dev ramps up.
## Overall Flow
```mermaid
flowchart TD
A[pnpm release --bump X] --> B{--tag provided?}
B -- no --> X1[abort]
B -- yes --> C{tag == latest?}
C -- yes --> X2[abort]
C -- no --> D[publish to specified dist-tag]
R[GitHub release published] --> V{tag matches semver?}
V -- no --> X3[abort]
V -- yes --> F{tag starts with v3?}
F -- yes --> G[checkout 3.x, regen templates, PR base=3.x]
F -- no --> H[checkout main, regen templates, PR base=main]
```1 parent 88c8aac commit bb508ea
3 files changed
Lines changed: 79 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
| 58 | + | |
| 59 | + | |
40 | 60 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
44 | 64 | | |
45 | 65 | | |
46 | 66 | | |
| |||
51 | 71 | | |
52 | 72 | | |
53 | 73 | | |
| 74 | + | |
| 75 | + | |
54 | 76 | | |
55 | 77 | | |
56 | 78 | | |
| |||
85 | 107 | | |
86 | 108 | | |
87 | 109 | | |
| 110 | + | |
88 | 111 | | |
89 | 112 | | |
90 | 113 | | |
91 | 114 | | |
92 | 115 | | |
93 | 116 | | |
94 | 117 | | |
95 | | - | |
| 118 | + | |
96 | 119 | | |
97 | 120 | | |
98 | 121 | | |
| |||
103 | 126 | | |
104 | 127 | | |
105 | 128 | | |
106 | | - | |
| 129 | + | |
107 | 130 | | |
108 | 131 | | |
109 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | | - | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
117 | 122 | | |
118 | 123 | | |
119 | 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 | + | |
120 | 161 | | |
121 | 162 | | |
122 | 163 | | |
| |||
145 | 186 | | |
146 | 187 | | |
147 | 188 | | |
| 189 | + | |
148 | 190 | | |
149 | 191 | | |
150 | 192 | | |
| |||
0 commit comments