Executing a custom hook¶
experimental
To further streamline the release workflow, nsv
adds support for executing a custom hook before tagging a repository with the next semantic version. The hook's contents are passed to a shell interpreter, which, therefore, supports both inline shell commands or a path to a script, maximizing reconfigurability.
A hooks context¶
nsv
injects the following environment variables into the hooks context:
Variable Name | Description | Example |
---|---|---|
NSV_PREV_TAG |
The previous semantic version | 0.2.0 |
NSV_NEXT_TAG |
The next calculated semantic version based on the commit history | 0.2.1 |
NSV_WORKING_DIRECTORY |
The current execution path. Will be a sub-directory for a monorepo | src/ui |
Let's patch the semantic version within a Cargo.toml
file to put it into practice.
-
Add a script to your project (
scripts/patch.sh
) for patching the file: -
Run
nsv
with the provided hook: