@releasekit/release 0.3.0-next.4 → 0.3.1

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
@@ -20,6 +20,8 @@ npm install -g @releasekit/release
20
20
  pnpm add -g @releasekit/release
21
21
  ```
22
22
 
23
+ > **Note:** This package is ESM only and requires Node.js 20+.
24
+
23
25
  ## Quick Start
24
26
 
25
27
  ```bash
@@ -48,6 +50,8 @@ If no releasable changes are found after step 1, the command exits with code 0 a
48
50
 
49
51
  ## CLI Reference
50
52
 
53
+ ### `releasekit release`
54
+
51
55
  | Flag | Description | Default |
52
56
  |------|-------------|---------|
53
57
  | `-c, --config <path>` | Path to config file | `releasekit.config.json` |
@@ -56,6 +60,7 @@ If no releasable changes are found after step 1, the command exits with code 0 a
56
60
  | `-p, --prerelease [id]` | Create prerelease version | — |
57
61
  | `-s, --sync` | Synchronized versioning across all packages | `false` |
58
62
  | `-t, --target <packages>` | Target specific packages (comma-separated) | all |
63
+ | `--branch <name>` | Git branch to push to | current branch |
59
64
  | `--skip-notes` | Skip changelog generation | `false` |
60
65
  | `--skip-publish` | Skip registry publishing and git operations | `false` |
61
66
  | `--skip-git` | Skip git commit/tag/push | `false` |
@@ -66,6 +71,22 @@ If no releasable changes are found after step 1, the command exits with code 0 a
66
71
  | `-q, --quiet` | Suppress non-error output | `false` |
67
72
  | `--project-dir <path>` | Project directory | cwd |
68
73
 
74
+ ### `releasekit preview`
75
+
76
+ Posts a release preview comment on a pull request showing what would be released if merged.
77
+
78
+ | Flag | Description | Default |
79
+ |------|-------------|---------|
80
+ | `-c, --config <path>` | Path to config file | `releasekit.config.json` |
81
+ | `-d, --dry-run` | Print comment markdown to stdout instead of posting | `false` |
82
+ | `-p, --prerelease [id]` | Force prerelease preview (auto-detected by default) | — |
83
+ | `--stable` | Force stable release preview (graduation from prerelease) | `false` |
84
+ | `--pr <number>` | PR number (auto-detected from GitHub Actions) | — |
85
+ | `--repo <owner/repo>` | Repository (auto-detected from `GITHUB_REPOSITORY`) | — |
86
+ | `--project-dir <path>` | Project directory | cwd |
87
+
88
+ The preview command reads PR labels to determine release behavior. See [CI Configuration](#ci-configuration) for label configuration.
89
+
69
90
  ## Usage Examples
70
91
 
71
92
  ### In CI (GitHub Actions)
@@ -91,10 +112,10 @@ jobs:
91
112
  if: "!contains(github.event.head_commit.message, '[skip ci]')"
92
113
  runs-on: ubuntu-latest
93
114
  steps:
94
- - uses: actions/checkout@v4
115
+ - uses: actions/checkout@v6
95
116
  with:
96
117
  fetch-depth: 0
97
- - uses: actions/setup-node@v4
118
+ - uses: actions/setup-node@v6
98
119
  - run: npm install -g @releasekit/release
99
120
  - run: releasekit release
100
121
  ```
@@ -144,14 +165,116 @@ if (result) {
144
165
 
145
166
  ## Configuration
146
167
 
147
- All configuration is shared via `releasekit.config.json`. The release command reads the `version`, `notes`, and `publish` sections as needed.
168
+ Create a `releasekit.config.json` in your project root. Add `$schema` for editor autocompletion and validation:
169
+
170
+ ```json
171
+ {
172
+ "$schema": "https://goosewobbler.github.io/releasekit/schema.json",
173
+ "version": {
174
+ "preset": "angular",
175
+ "packages": ["./"]
176
+ }
177
+ }
178
+ ```
148
179
 
149
- See the individual package READMEs for configuration details:
180
+ The release command reads the `version`, `notes`, and `publish` sections. See the individual package READMEs for all available options:
150
181
 
151
182
  - [@releasekit/version](../version/README.md) — versioning options
152
183
  - [@releasekit/notes](../notes/README.md) — changelog options
153
184
  - [@releasekit/publish](../publish/README.md) — publishing options
154
185
 
186
+ ### CI Configuration
187
+
188
+ The `ci` section controls automation behavior:
189
+
190
+ ```jsonc
191
+ {
192
+ "ci": {
193
+ // How releases are delivered
194
+ "releaseStrategy": "direct", // "manual" | "direct" | "standing-pr" | "scheduled"
195
+
196
+ // What triggers a release
197
+ "releaseTrigger": "label", // "commit" | "label"
198
+
199
+ // Enable/disable PR preview comments
200
+ "prPreview": true,
201
+
202
+ // Customise PR label names
203
+ "labels": {
204
+ "stable": "release:stable",
205
+ "prerelease": "release:prerelease",
206
+ "skip": "release:skip",
207
+ "major": "release:major",
208
+ "minor": "release:minor",
209
+ "patch": "release:patch"
210
+ }
211
+ }
212
+ }
213
+ ```
214
+
215
+ #### Release Trigger
216
+
217
+ **`label`** (default) — A PR label (`release:patch`, `release:minor`, or `release:major`) is required to trigger a release. The label determines the bump type. PRs without a release label will not trigger a release when merged.
218
+
219
+ **`commit`** — Conventional commits drive the bump type automatically. Every merge can trigger a release. Use the `release:skip` label to prevent a release, or `release:major` to override the commit-derived bump to major.
220
+
221
+ Both modes support `release:stable` and `release:prerelease` as modifiers.
222
+
223
+ #### Release Strategy
224
+
225
+ | Strategy | Description |
226
+ |----------|-------------|
227
+ | `direct` | Release is triggered when a PR is merged to the main branch |
228
+ | `manual` | Releases are triggered manually (e.g. via `workflow_dispatch`) |
229
+ | `standing-pr` | Changes accumulate in a standing release PR *(planned)* |
230
+ | `scheduled` | Releases are triggered on a schedule *(planned)* |
231
+
232
+ ### PR Preview
233
+
234
+ The `releasekit preview` command posts a comment on pull requests showing what would be released. It reads PR labels from GitHub and adapts its messaging based on `releaseStrategy` and `releaseTrigger`.
235
+
236
+ Add this workflow to `.github/workflows/release-preview.yml`:
237
+
238
+ ```yaml
239
+ name: Release Preview
240
+
241
+ on:
242
+ pull_request:
243
+ branches: [main]
244
+ types: [opened, synchronize, labeled, unlabeled]
245
+
246
+ concurrency:
247
+ group: release-preview-${{ github.event.pull_request.number }}
248
+ cancel-in-progress: true
249
+
250
+ permissions:
251
+ pull-requests: write
252
+ contents: read
253
+
254
+ jobs:
255
+ preview:
256
+ name: Release Preview
257
+ runs-on: ubuntu-latest
258
+ steps:
259
+ - uses: actions/checkout@v6
260
+ with:
261
+ fetch-depth: 0
262
+
263
+ - uses: actions/setup-node@v6
264
+ with:
265
+ node-version: '20'
266
+
267
+ - name: Install dependencies
268
+ run: npm ci
269
+
270
+ - name: Release preview
271
+ run: npx releasekit preview
272
+ env:
273
+ GITHUB_TOKEN: ${{ github.token }}
274
+ ```
275
+
276
+ A template is also available at [`templates/workflows/release-preview.yml`](../../templates/workflows/release-preview.yml).
277
+
155
278
  ## License
156
279
 
157
280
  MIT
@@ -0,0 +1,45 @@
1
+ import {
2
+ EXIT_CODES,
3
+ runRelease
4
+ } from "./chunk-I5ABZWVU.js";
5
+
6
+ // src/release-command.ts
7
+ import { Command } from "commander";
8
+ function createReleaseCommand() {
9
+ return new Command("release").description("Run the full release pipeline").option("-c, --config <path>", "Path to config file").option("-d, --dry-run", "Preview all steps without side effects", false).option("-b, --bump <type>", "Force bump type (patch|minor|major)").option("-p, --prerelease [identifier]", "Create prerelease version").option("-s, --sync", "Use synchronized versioning across all packages", false).option("-t, --target <packages>", "Target specific packages (comma-separated)").option("--branch <name>", "Override the git branch used for push").option("--skip-notes", "Skip changelog generation", false).option("--skip-publish", "Skip registry publishing and git operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-github-release", "Skip GitHub release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("-j, --json", "Output results as JSON", false).option("-v, --verbose", "Verbose logging", false).option("-q, --quiet", "Suppress non-error output", false).option("--project-dir <path>", "Project directory", process.cwd()).action(async (opts) => {
10
+ const options = {
11
+ config: opts.config,
12
+ dryRun: opts.dryRun,
13
+ bump: opts.bump,
14
+ prerelease: opts.prerelease,
15
+ sync: opts.sync,
16
+ target: opts.target,
17
+ branch: opts.branch,
18
+ skipNotes: opts.skipNotes,
19
+ skipPublish: opts.skipPublish,
20
+ skipGit: opts.skipGit,
21
+ skipGithubRelease: opts.skipGithubRelease,
22
+ skipVerification: opts.skipVerification,
23
+ json: opts.json,
24
+ verbose: opts.verbose,
25
+ quiet: opts.quiet,
26
+ projectDir: opts.projectDir
27
+ };
28
+ try {
29
+ const result = await runRelease(options);
30
+ if (options.json && result) {
31
+ console.log(JSON.stringify(result, null, 2));
32
+ }
33
+ if (!result) {
34
+ process.exit(0);
35
+ }
36
+ } catch (error) {
37
+ console.error(error instanceof Error ? error.message : String(error));
38
+ process.exit(EXIT_CODES.GENERAL_ERROR);
39
+ }
40
+ });
41
+ }
42
+
43
+ export {
44
+ createReleaseCommand
45
+ };