semantic-release-next-version 0.1.3 → 0.1.5

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
@@ -88,15 +88,11 @@ jobs:
88
88
  run: |
89
89
  set -euo pipefail
90
90
  MODE=""
91
- if [ "${{ github.ref }}" = "refs/heads/main" ]; then MODE="--release"; fi
91
+ if [ "${{ github.ref }}" = "refs/heads/main" ]; then MODE="--release --on-no-release preview"; fi
92
92
  VERSION=$(npx next-version-helper $MODE)
93
- if [ -z "$VERSION" ]; then
94
- echo "semantic-release did not return a next version." >&2
95
- exit 1
96
- fi
97
93
  echo "version=$VERSION" >> "$GITHUB_OUTPUT"
98
- env:
99
- DEBUG: semantic-release-next-version,semantic-release:* # to enable debugging
94
+ # env:
95
+ # DEBUG: semantic-release-next-version,semantic-release:* # enable for debugging
100
96
  ```
101
97
 
102
98
  Now other jobs can use the version:
@@ -119,6 +115,9 @@ npx next-version-helper
119
115
  npx next-version-helper --release
120
116
  # → 0.4.0
121
117
 
118
+ npx next-version-helper --release --on-no-release preview
119
+ # → 0.4.0-preview-abc1234 (when no releasable commits)
120
+
122
121
  # When you run from outside the repo (e.g. a packed tarball):
123
122
  npx next-version-helper --cwd /path/to/your/checkout --release
124
123
  ```
@@ -131,7 +130,7 @@ import { getNextVersion } from 'semantic-release-next-version'
131
130
  const version = await getNextVersion({
132
131
  cwd: process.cwd(),
133
132
  release: false,
134
- mainBranch: 'main', // override if your primary branch differs
133
+ defaultBranch: 'main', // override if your primary branch differs
135
134
  })
136
135
  console.log(version)
137
136
  ```
@@ -141,8 +140,13 @@ console.log(version)
141
140
  ## CLI options
142
141
 
143
142
  - `--release` / `-r`: return plain `x.y.z` (no preview suffix).
143
+ - `--on-no-release <mode>`: behavior when `--release` has no releasable commits:
144
+ - `error` (default): exit with an error.
145
+ - `current`: return `<currentVersion>`.
146
+ - `preview`: return `<currentVersion>-preview-<hash>`.
144
147
  - `--cwd <path>`: run against a different working directory (useful when you call from a temp folder).
145
- - `--main-branch <name>`: set the primary release branch (default: `main`).
148
+ - `--default-branch <name>`: set the primary release branch (default: `main`).
149
+ - `--main-branch <name>`: deprecated alias for `--default-branch`.
146
150
  - `--help` / `--version`
147
151
 
148
152
  ---
@@ -151,10 +155,16 @@ console.log(version)
151
155
 
152
156
  - On `main` branch with `--release` → returns `x.y.z`.
153
157
  - On any branch without `--release` → returns `x.y.z-preview-<hash>`.
154
- - If there is no new release exits with an error
158
+ - If there is no new release in preview mode returns `<currentVersion>-preview-<hash>`.
159
+ - If there is no new release with `--release`:
160
+ - `--on-no-release error` (default) → exits with an error.
161
+ - `--on-no-release current` → returns `<currentVersion>`.
162
+ - `--on-no-release preview` → returns `<currentVersion>-preview-<hash>`.
163
+ - `currentVersion` is resolved from the latest semantic version tag, then falls back to `package.json` version.
155
164
  - Uses `@semantic-release/commit-analyzer` by default (must be installed).
156
- - Main branch defaults to `main`; override with `--main-branch` or `mainBranch` in code.
165
+ - Default branch defaults to `main`; override with `--default-branch` or `defaultBranch` in code.
157
166
  - `--cwd` lets you run the CLI outside the repo root (for example after `npm pack`).
167
+ - Recommended for main-branch packaging/smoke flows: `--release --on-no-release preview` to keep artifacts clearly non-stable and reduce accidental publish risk.
158
168
 
159
169
  ---
160
170
 
@@ -177,4 +187,4 @@ MIT
177
187
 
178
188
  - Enable verbose logs by setting `DEBUG=semantic-release-next-version` (optionally add `,semantic-release:*` for semantic-release internals).
179
189
  - In GitHub Actions, you can set `DEBUG` in a step that runs the CLI (the CI smoke test does this).
180
- - When running from a packed tarball or temp dir, pass `--cwd /path/to/repo` and `--main-branch <branch>` so branch detection stays correct.
190
+ - When running from a packed tarball or temp dir, pass `--cwd /path/to/repo` and `--default-branch <branch>` so branch detection stays correct.