You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Document CRAFT_NEW_VERSION and CRAFT_OLD_VERSION for pre-release command (#719)
## Summary
Document the `CRAFT_NEW_VERSION` and `CRAFT_OLD_VERSION` environment
variables in the pre-release command documentation. Using environment
variables is the recommended way to handle version bumping in custom
scripts as it is safer and more explicit than relying on positional
arguments.
## Changes
- Updated `docs/src/content/docs/configuration.md` to include
environment variable documentation.
- Updated the example script to demonstrate usage of
`CRAFT_NEW_VERSION`.
- Verified that existing tests in
`src/commands/__tests__/prepare.test.ts` already cover the propagation
of these environment variables.
Copy file name to clipboardExpand all lines: docs/src/content/docs/configuration.md
+47-39Lines changed: 47 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,22 +23,28 @@ This command runs on your release branch as part of `craft prepare`. Default: `b
23
23
preReleaseCommand: bash scripts/bump-version.sh
24
24
```
25
25
26
+
The command is executed with the following environment variables:
27
+
28
+
- `CRAFT_OLD_VERSION`: The previous version (or `0.0.0` if no previous version exists)
29
+
- `CRAFT_NEW_VERSION`: The new version being released
30
+
26
31
The script should:
27
-
- Accept old and new version as the last two arguments
28
-
- Replace version occurrences
32
+
33
+
- Use these environment variables to perform version replacement
29
34
- Not commit changes
30
35
- Not change git state
31
36
37
+
> **Note:** For backward compatibility, the old and new versions are also passed as the last two command-line arguments to the script, but using environment variables is safer and recommended.
38
+
32
39
Example script:
33
40
34
41
```bash
35
42
#!/bin/bash
36
43
set -eux
37
-
OLD_VERSION="${1}"
38
-
NEW_VERSION="${2}"
39
44
45
+
# Use CRAFT_NEW_VERSION provided by craft
40
46
export npm_config_git_tag_version=false
41
-
npm version "${NEW_VERSION}"
47
+
npm version "${CRAFT_NEW_VERSION}"
42
48
```
43
49
44
50
## Post-release Command
@@ -94,10 +100,10 @@ Auto mode uses `.github/release.yml` to categorize PRs. This file follows [GitHu
94
100
95
101
Craft extends GitHub's format with two additional fields:
0 commit comments