A script which will automatically increment your app package version in accordance with conventional commits
- Most version bumping scripts only focus on just the version bumping. automatic-versioning takes into account your git changes and automatically increments the version number based on your last commit message only if there are changes in your directory, a feature which is highly useful in monorepos.
- Git installed and configured
# using npm
npm install @sliit-foss/automatic-versioning
# using yarn
yarn add @sliit-foss/automatic-versioning
- Add the following script to your package.json
"scripts": {
"bump-version": "npx automatic-versioning --name=<package_name>"
}
- then:
# using npm
npm run bump-version
# using yarn
yarn bump-version
"dependencies": {
"@commitlint/cli": "^17.0.1",
"@commitlint/config-conventional": "^17.0.0",
"husky": "^4.3.8"
}
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"post-commit": "HUSKY_SKIP_HOOKS=1 yarn bump-version",
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
- Feature! | Feat! | Fix! | Patch! - bump major version
- Feature | Feat - bump minor version
- Fix | Patch - bump patch version
- By default automatic-versioning will commit the newly incremented version to source control. To disable this behavior, add the following to your script: "--skip-commit"
npx automatic-versioning --name=<package_name> --skip-commit
git commit -m "Feat: some feature --no-bump"
npx automatic-versioning --name=<package_name> --root=<custom_dir>
npx automatic-versioning --name=<package_name> --recursive
-
If this option is specified and the current branch matches it, the versioning will be evaluated as follows
- Feat! --> Premajor
- Feat --> Preminor
- Fix --> Prepatch
npx automatic-versioning --name=<package_name> --prerelease-branch=<branch_name>
- If this is specified, the versioning will always be one of prerelease, premajor, preminor or prepatch depending on the above commit mapping
npx automatic-versioning --name=<package_name> --prerelease
npx automatic-versioning --name=<package_name> --prerelease-tag=<name>
- A list of comma separated prefixes to ignore when evaluating the commit message. By default we stop searching for commits once we come across any prefix considered by commitlint as valid prefixes. You can use this option to ignore a few of them if the need arises
npx automatic-versioning --name=<package_name> --ignore-prefixes=ci,docs
-
--no-commit-edit
option has been removed as commits no longer cause problems with the versioning script -
--no-commit
option has been renamed to--skip-commit