@bensandee/tooling 0.105.0 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -206,6 +206,7 @@ Renovate moves the pinned `node` version, but only within its current major -- a
206
206
  | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
207
207
  | `tooling release:changesets` | Changesets version/publish for Forgejo CI. A prerelease package moves only its own `<name>@<version>` tag; `<name>@latest`, `<name>@vX` and `<name>@vX.Y` move only for a release (see `release:simple`). Flags: `--dry-run`, `--verbose`. Env: `FORGEJO_SERVER_URL`, `FORGEJO_REPOSITORY`, `RELEASE_TOKEN`. |
208
208
  | `tooling release:simple` | Streamlined release using commit-and-tag-version. Flags: `--release-as`, `--first-release`, `--prerelease`, `--verbose`. Env: `RELEASE_TOKEN` (required on every platform). |
209
+ | `tooling release:snapshot` | Cut the rolling prerelease for every package in `.tooling.json#snapshot`, on a push that cut no real release. Flags: `--build` (the run number outside CI), `--dry-run`, `--json`, `--verbose`. Env: `GITHUB_SHA`, `GITHUB_RUN_NUMBER`, `RELEASE_TOKEN`, `GITHUB_OUTPUT`. |
209
210
  | `tooling release:trigger` | Trigger a release workflow. |
210
211
  | `tooling workflow:dispatch` | Dispatch a `workflow_dispatch` event for any workflow in any repo on the same git host. Flags: `--repo`, `--workflow` (required), `--ref`, `--input key=value` (repeatable). |
211
212
  | `tooling changesets:merge` | Merge a changesets version PR. Gated on a live read of the PR; refuses an empty version PR. On Forgejo, a first `mergeable: false` re-reads once after a short delay before refusing, since the forge reports `false` both for a conflict and while still checking. |
@@ -309,16 +310,29 @@ If the script runs but writes no files to `release-assets/`, `release:assets` fa
309
310
  }
310
311
  ```
311
312
 
312
- | Field | Description |
313
- | --------- | ---------------------------------------------------------------------------------------- |
314
- | `file` | Path to the artifact, relative to the project root (required). |
315
- | `command` | argv run before upload (optional; omit for pre-built files). Not interpreted by a shell. |
316
- | `name` | Asset name in the release (optional; defaults to the file's basename). |
313
+ | Field | Description |
314
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
315
+ | `file` | Path to the artifact, relative to the project root. Set exactly one of `file` and `files`. |
316
+ | `files` | Glob patterns relative to the project root, resolved after the build runs; every match uploads under its own basename. Set exactly one of `file` and `files`. |
317
+ | `command` | argv run before upload (optional; omit for pre-built files). Not interpreted by a shell. |
318
+ | `name` | Asset name in the release (optional; a `file` entry only -- a `files` match keeps its basename, since one name cannot serve many files). |
319
+ | `package` | The workspace package this asset belongs to (optional; required in a monorepo once `snapshot` is set). See "Which release a build serves" below. |
317
320
 
318
321
  Convention and overrides coexist -- a repo can use both.
319
322
 
320
323
  Works for both `changesets` and `simple` release strategies, on Forgejo (via API upload) and GitHub (via `gh release upload --clobber`). The asset step in the workflow is gated on the release itself having published/pushed, so failed releases never upload stale artifacts.
321
324
 
325
+ **Which release a build serves.** A build that takes its version from outside `package.json` -- Gradle, a generated manifest -- needs to know what it is building, and a monorepo build needs to know which package it belongs to. Every build is handed four variables describing the release it serves, merged over its own environment:
326
+
327
+ | Variable | Value |
328
+ | ---------------------- | --------------------------------------- |
329
+ | `RELEASE_VERSION` | The version being released. |
330
+ | `RELEASE_TAG` | The tag that release carries. |
331
+ | `RELEASE_PRERELEASE` | `true` or `false`. |
332
+ | `RELEASE_BUILD_NUMBER` | The CI run number, or empty outside CI. |
333
+
334
+ An entry naming a `package`, and a `build:release-assets` script in a package directory, belong to that package: they run once per release of that package at HEAD, and upload to that release only. An entry with no `package` belongs to the root package in a single-package repo, which is the old behaviour; in a monorepo it belongs to no package, so it builds once and uploads to every release at HEAD, and gets the four variables only when exactly one release is at HEAD.
335
+
322
336
  #### Version stamping
323
337
 
324
338
  For a repo whose released artifact carries its version somewhere other than `package.json` -- a WordPress theme's `style.css` header, a plugin banner, a template file -- declare where the version goes and let `release:assets` write it in:
@@ -329,11 +343,12 @@ For a repo whose released artifact carries its version somewhere other than `pac
329
343
  }
330
344
  ```
331
345
 
332
- | Field | Description |
333
- | -------- | ------------------------------------------------------------------------------------------ |
334
- | `file` | Path to the file whose version line gets stamped, relative to the project root (required). |
335
- | `prefix` | Literal string (never a pattern) the target line must start with (required). |
336
- | `suffix` | Literal string (never a pattern) the target line must end with (optional; default: none). |
346
+ | Field | Description |
347
+ | --------- | ----------------------------------------------------------------------------------------------------------------- |
348
+ | `file` | Path to the file whose version line gets stamped, relative to the project root (required). |
349
+ | `prefix` | Literal string (never a pattern) the target line must start with (required). |
350
+ | `suffix` | Literal string (never a pattern) the target line must end with (optional; default: none). |
351
+ | `package` | The workspace package whose release this stamp carries (optional; required in a monorepo once `snapshot` is set). |
337
352
 
338
353
  `prefix` and `suffix` are literal strings, not regexes -- the target line is read straight off `prefix + version + suffix`:
339
354
 
@@ -346,10 +361,47 @@ For a repo whose released artifact carries its version somewhere other than `pac
346
361
  | `<version>1.2.3</version>` | `"<version>"` | `"</version>"` |
347
362
  | `define('FOO_VERSION', '1.2.3');` | `"define('FOO_VERSION', '"` | `"');"` |
348
363
 
349
- `release:assets` stamps every configured file before building assets, then verifies the stamp survived the build. Exactly one line in the file must match `prefix`/`suffix` or the release fails loudly -- zero matches means the config is broken, and more than one is an ambiguous config that needs a more specific `prefix` or a second entry. The stamp is never committed: the tracked copy of the file keeps its placeholder version on purpose, so there is only ever one source of truth (`package.json#version`) and nothing to drift. Run `bst release:assets --dry-run` to rehearse a `versionStamp` config locally, with no forge access and no release -- the rehearsal does still write the stamp, so it leaves the tracked file modified in your working tree. Discard it with `git checkout -- <file>`; committing it is exactly the drift this design exists to prevent.
364
+ `release:assets` stamps every configured file before building assets, then verifies the stamp survived the build; `release:snapshot` does the same for the package it cuts, stamping the snapshot version. Exactly one line in the file must match `prefix`/`suffix` or the release fails loudly -- zero matches means the config is broken, and more than one is an ambiguous config that needs a more specific `prefix` or a second entry. The stamp is never committed: the tracked copy of the file keeps its placeholder version on purpose, so there is only ever one source of truth (`package.json#version`) and nothing to drift. Run `bst release:assets --dry-run` to rehearse a `versionStamp` config locally, with no forge access and no release -- the rehearsal does still write the stamp, so it leaves the tracked file modified in your working tree. Discard it with `git checkout -- <file>`; committing it is exactly the drift this design exists to prevent.
350
365
 
351
366
  `repo:sync --check` validates that every `versionStamp[].file` exists and still has exactly one matching line -- it never compares the stamped value to `package.json#version`, since the tracked value is deliberately stale.
352
367
 
368
+ #### Snapshot channel
369
+
370
+ A repo on the `changesets` strategy can ship a second, rolling kind of release: a prerelease from every push to the default branch, so testers get each change before anyone writes a changeset. Declare it in `.tooling.json`:
371
+
372
+ ```json
373
+ {
374
+ "snapshot": { "preid": "alpha", "keep": 3, "packages": ["@acme/app"] }
375
+ }
376
+ ```
377
+
378
+ | Field | Description |
379
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
380
+ | `preid` | The prerelease identifier, `[a-z][a-z0-9]*` (required). `alpha` gives `1.2.6-alpha.42`. |
381
+ | `keep` | How many snapshots to keep per package before the oldest are deleted (optional; default `3`). |
382
+ | `packages` | Which packages to snapshot, by name. Optional in a single-package repo, where it defaults to the root package; **required in a monorepo**. |
383
+
384
+ A monorepo asks you to name the list because most monorepos have packages nobody installs from a snapshot; bst never picks them for you, and `repo:sync` refuses a missing list or a name with no package behind it.
385
+
386
+ When the key is set, the generated `ci.yml` gains a `snapshot` job. It runs after `check`, on the default branch only, and only when `check` cut no real release -- a push whose Version Packages PR merged ships the version, never also a snapshot of it. It runs `bst release:snapshot`, and it triggers no deploy dispatch and no post-release hook: both belong to the stable channel.
387
+
388
+ The job exposes four outputs, in the same form `check` does, so a later job can treat the two channels alike:
389
+
390
+ | Output | Value |
391
+ | ----------- | ----------------------------------------------------------------------------------- |
392
+ | `published` | `true` once every listed package's prerelease exists. |
393
+ | `version` | The first listed package's version. |
394
+ | `tag` | The first listed package's tag. |
395
+ | `packages` | A JSON array of `{ "name": ..., "version": ..., "tag": ... }`, one per package cut. |
396
+
397
+ Each package's version is `<next>-<preid>.<build>`. `<next>` is the version the pending changesets would give that package, including a bump it gets as a dependent, or its current patch raised by one when none is pending -- so every listed package snapshots on every push. `<build>` is the CI run number, `GITHUB_RUN_NUMBER`, which both forges set; outside CI, pass `--build <n>`. The version goes into that package's `package.json` in the working tree only, and the release is created as a prerelease targeting the commit the job checked out. Nothing is committed, no tag is pushed by the command, and no floating tag moves.
398
+
399
+ Old snapshots are pruned per package: releases whose tags match that package's own snapshot pattern, sorted newest first, beyond `keep` are deleted with their tags. A stable release, another package's snapshot, or another `preid` never matches, so a prune cannot reach them.
400
+
401
+ One thing to know about the run number: it restarts at 1 for each workflow file, and a re-run reuses its number. A version built from it is unique per run of that file, not per commit -- if you renumber after renaming or moving the workflow, pick a new `preid` so the new series cannot collide with the old.
402
+
403
+ Run `bst release:snapshot --dry-run` to see the versions and tags with no forge access and no writes. `--json` prints one document, `{ published, packages }`, with the builds captured rather than inherited.
404
+
353
405
  ### Coverage tracking
354
406
 
355
407
  | Command | Description |