1 # release-banner
2
3 Generates the banner images used around Medusa releases and the Cloud changelog.
4 Two types are supported:
5
6 | Type | What it is |
7 | --- | --- |
8 | `release` | The banner embedded in the CMS block of a GitHub release's notes — the dark pill holding the Medusa logomark and the version, as used on [v2.13.0](https://github.com/medusajs/medusa/releases/tag/v2.13.0). |
9 | `cloud-changelog` | The banner heading an entry in the Medusa Cloud changelog — a pill holding the logomark, the Cloud wordmark and the entry's date. |
10
11 Banners are rendered with [satori](https://github.com/vercel/satori) (element
12 tree → SVG) and [resvg](https://github.com/yisibl/resvg-js) (SVG → PNG). Neither
13 needs a browser, so a render is a plain `node` step that takes well under a
14 second — the four banners the release preview produces take about 0.6s in total.
15
16 ## Usage
17
18 ```bash
19 cd www/utils
20 yarn install
21 yarn workspace release-banner build
22 ```
23
24 Then, from `www/utils/packages/release-banner`:
25
26 ```bash
27 # Render to out/v2.19.0.png
28 yarn render --version 2.19.0
29
30 # Or straight from dist
31 node dist/cli.js render --version 2.19.0 --width 1600 --out /tmp/banner.png
32
33 # A Cloud changelog banner
34 node dist/cli.js render --type cloud-changelog --date "Aug 17"
35 ```
36
37 Every command takes `--type <release | cloud-changelog>`, defaulting to
38 `release`.
39
40 ### `render`
41
42 | Flag | Description |
43 | --- | --- |
44 | `--type <type>` | Banner type. Defaults to `release`. |
45 | `-v, --version <version>` | `release`: version to render, with or without the `v` prefix. Required. |
46 | `-d, --date <date>` | `cloud-changelog`: date shown after the wordmark, rendered exactly as given. Required. |
47 | `-o, --out <path>` | Output file. Defaults to `out/<label>.png` — the version, or the date slugified. |
48 | `-f, --format <format>` | `png` or `svg`. Inferred from `--out` when it ends in `.svg`. |
49 | `-w, --width <px>` | Canvas width. Defaults to the type's reference width; the height and every dimension in the spec scale with it. |
50 | `--font-size <px>` | Override the main text size — the version, or the Cloud wordmark. |
51 | `--gap <px>` | Override the space between the logomark and the text. |
52
53 ### `preview`
54
55 ```bash
56 yarn preview
57 yarn preview --type cloud-changelog
58 ```
59
60 Renders the type's default spread and writes a page to review it on. For
61 `release` — which reproduces an existing banner — the page also puts the
62 generated `v2.13.0` next to the original, plus a difference overlay where black
63 means identical and an amplify toggle brings out the small stuff.
64
65 Pass values to render them alongside the default spread — versions for
66 `release`, dates for `cloud-changelog`:
67
68 ```bash
69 yarn preview v2.20.0 v3.0.0
70 ```
71
72 For `release`, the reference version is rendered whatever you pass, since the
73 comparison at the top of the page needs it. `cloud-changelog` has no hosted
74 reference to compare against, so its page is the grid alone.
75
76 | Flag | Description |
77 | --- | --- |
78 | `--type <type>` | Banner type. Defaults to `release`. |
79 | `-o, --out-dir <path>` | Output directory. Defaults to `out`. |
80 | `--no-open` | Write the page without opening it. Also skipped when `CI` is set. |
81
82 ### `upload`
83
84 Renders a banner and uploads it to the type's folder in Cloudinary, printing the
85 delivery URL — the only thing it writes to stdout, so a caller can read it
86 straight off:
87
88 ```bash
89 node dist/cli.js upload --version 2.19.0
90 # https://res.cloudinary.com/<cloud>/image/upload/v.../Releases/v2-19-0-6df68c.png
91 ```
92
93 | Flag | Description |
94 | --- | --- |
95 | `--type <type>` | Banner type. Defaults to `release`. |
96 | `-v, --version <version>` | `release`: version to render and upload. Required. |
97 | `-d, --date <date>` | `cloud-changelog`: date to render. Required. |
98 | `--folder <folder>` | Cloudinary folder. Defaults to the type's own: `Releases` or `Cloud Changelog`. |
99 | `--dry-run` | Render and report the target public ID without uploading. |
100
101 Credentials come from the environment — either `CLOUDINARY_URL`, which is the
102 SDK's own convention and keeps this to a single secret, or all three of
103 `CLOUDINARY_CLOUD_NAME`, `CLOUDINARY_API_KEY` and `CLOUDINARY_API_SECRET`.
104
105 For local runs the CLI reads a `.env` in the working directory, which is
106 gitignored:
107
108 ```bash
109 # www/utils/packages/release-banner/.env
110 CLOUDINARY_URL=cloudinary://<key>:<secret>@<cloud>
111 ```
112
113 A variable that is already set always wins, so this changes nothing in CI, where
114 the credentials arrive as real environment variables. Nothing else in the package
115 reads `.env` — importing it as a library leaves your process environment alone.
116
117 Public IDs are slugified and then given a **random six-character suffix**:
118 `v2.19.0` uploads as `Releases/v2-19-0-6df68c`. Slugifying is what makes the ID
119 safe — Cloudinary reads the segment after a public ID's last dot as the file
120 format, so `v2.19.0` would otherwise deliver as `v2.19` in a `0` format, and
121 dashes match the banners uploaded by hand before this was automated.
122
123 The suffix means **every upload gets its own URL**. A URL that has been published
124 therefore keeps showing the image it showed when it was published, since nothing
125 later can be uploaded over it. The trade-off is that re-running for the same
126 version no longer updates the asset in place — it adds another one, and the
127 previous one stays in the media library until someone clears it out.
128
129 `--dry-run` draws a fresh suffix like any other run, so it reports the shape of
130 the target rather than the ID a real upload would land on.
131
132 ## Programmatic use
133
134 ```ts
135 import { renderPng } from "release-banner"
136
137 const release = await renderPng({ type: "release", version: "v2.19.0" })
138 const changelog = await renderPng({
139 type: "cloud-changelog",
140 date: "Aug 17",
141 })
142 ```
143
144 `renderSvg` returns the intermediate SVG, and both accept a partial `spec` to
145 override any measurement for a single render. The input is a union discriminated
146 by `type`, so the fields and the spec each type accepts are checked at the call
147 site.
148
149 ## In the Draft Release workflow
150
151 [`.github/workflows/draft-release.yml`](../../../../.github/workflows/draft-release.yml)
152 renders and uploads the release banner, then inserts it into the notes:
153
154 1. `upload` runs **before** the Claude step, so a misconfigured upload surfaces
155 before spending a Claude run. It needs the `CLOUDINARY_URL` repository secret.
156 Each run uploads a new asset, so re-running the workflow for a version leaves
157 the earlier banner behind in Cloudinary.
158 2. After Claude writes the notes, a step splices `![<tag>](<url>)` into the CMS
159 block, above the title heading — matching where the v2.13.0 banner sits. The
160 banner is consumed by the CMS and never renders on the release page itself.
161
162 The upload step is `continue-on-error` and warns rather than failing: the notes
163 are the deliverable and the banner is decoration, so a Cloudinary outage should
164 not block a release. When it is skipped, the insertion step is skipped too and the
165 notes go out unchanged. Flip `continue-on-error` to `false` if a missing banner
166 should fail the run instead.
167
168 ## Adding or changing a banner type
169
170 Each type lives in its own directory under [`src/banners`](./src/banners) and is
171 described by one `BannerDefinition`:
172
173 ```
174 src/banners/<type>/
175 spec.ts # the spec's shape, and its default values
176 template.ts # the input type, and the element tree built from it
177 index.ts # the definition: spec, folder, publicId, label, preview inputs
178 ```
179
180 Register the definition in [`src/banners/index.ts`](./src/banners/index.ts) and
181 that is it — the renderer, the preview page, the uploader and the CLI all read
182 the type off the registry. The CLI is the one place that maps flags to a type's
183 input, in `inputFrom`.
184
185 A type's public ID is whatever its definition says identifies one banner: the
186 version for `release`, the date for `cloud-changelog`. Dates without a year
187 collide a year apart, so pass one that carries the year when two entries must not
188 overwrite each other.
189
190 ## Editing the design
191
192 A type's `spec.ts` holds every measurement — canvas size, geometry, gradients,
193 type size, and the sheen on the logomark and text. The numbers are in pixels at
194 the design's reference resolution and are scaled proportionally when `width`
195 differs, so the spec is the only place to touch when a design changes.
196
197 The release spec was derived by sampling the v2.13.0 banner rather than by eye,
198 and matches it to within 1–2px on pill geometry, padding, logomark size, type
199 size, and gradient colours. Against the original the render measures an RMSE of
200 10.1/255, with 0.47% of pixels differing by more than 24/255 — all of it 1px
201 antialiasing along glyph edges.
202
203 Satori supports a subset of CSS, which shapes how the templates are written:
204
205 - **Flexbox only.** No grid, no absolute positioning tricks; every container
206 needs an explicit `display: flex`.
207 - **The release rim is a nested element, not a border.** Satori has no
208 `border-image`, so the gradient rim is an outer element whose gradient
209 background is exposed by `borderWidth` worth of padding around the inner
210 surface.
211 - **The logomark is an `<img>` holding an SVG data URI**, since that is how
212 satori takes SVG. Its gradient lives inside that SVG.
213 - **Type does not auto-shrink.** Anything variable makes its container wider
214 rather than shrinking to fit — both pills size around their contents.
215 - **Shadow spread cannot be negative.** Satori draws spread as a stroke around
216 the shadow's shape, so a negative one emits a negative `stroke-width` that
217 panics resvg. The Cloud banner clamps it at zero and pulls the blur in to
218 compensate.
219
220 ## Fonts
221
222 Inter and Roboto Mono — the Cloud banner sets its date in mono — are read from
223 `packages/admin/dashboard/src/assets/fonts`, found by walking up to the monorepo
224 root. Nothing is downloaded at render time and there is no second copy of either
225 typeface to keep in step. System fonts are disabled in resvg so output cannot
226 drift between a laptop and CI.
227
228 Only the files listed in [`src/fonts.ts`](./src/fonts.ts) are loaded — both
229 families at weights 400 and 500. A design asking for anything else needs the file
230 added there first. Every loaded font goes to satori together and is picked by
231 `fontFamily`, so a template only names the one it wants.
232
233 ## Known deviations from the references
234
235 The two `.` separators sit a little tighter against the following digit in the
236 original than Inter's default metrics produce — around 20px at 3200px wide.
237 Overall text width, type size, and every other measurement match, and the
238 difference is only visible in an amplified diff. The original was most likely
239 kerned by hand in the design tool.
240
241 The Cloud banner matches the approved design to an RMSE of 3.63/255, with 0.14%
242 of pixels differing by more than 24/255 — all of it in the top half of the pill,
243 where the browser's inset highlight and the gradient it sits on rasterise a hair
244 differently in satori.