standard-version
is deprecated. If you're a GitHub user, I recommend release-please as an alternative. If you're unable to use GitHub Actions, or if you need to stick withstandard-version
for some other reason, you can use the commit-and-tag-version fork ofstandard-version
.
A utility for versioning using semver and CHANGELOG generation powered by Conventional Commits.
Having problems? Want to contribute? Join us on the node-tooling community Slack.
How It Works:
standard-version
.standard-version
will then do the following:
packageFiles
[1], falling back to the last git tag
.bump
the version in bumpFiles
[1] based on your commits.changelog
based on your commits (uses conventional-changelog under the hood).commit
including your bumpFiles
[1] and updated CHANGELOG.tag
with the new version number.bumpFiles
, packageFiles
and updaters
standard-version
uses a few key concepts for handling version bumping in your project.
packageFiles
– User-defined files where versions can be read from and be "bumped".
package.json
, manifest.json
packageFiles
are a subset of bumpFiles
.bumpFiles
– User-defined files where versions should be "bumped", but not explicitly read from.
package-lock.json
, npm-shrinkwrap.json
updaters
– Simple modules used for reading packageFiles
and writing to bumpFiles
.By default, standard-version
assumes you're working in a NodeJS based project... because of this, for the majority of projects you might never need to interact with these options.
That said, if you find your self asking How can I use standard-version for additional metadata files, languages or version files? – these configuration options will help!
standard-version
npm run
scriptInstall and add to devDependencies
:
npm i --save-dev standard-version
Add an npm run
script to your package.json
:
{ "scripts": { "release": "standard-version" } }
Now you can use npm run release
in place of npm version
.
This has the benefit of making your repo/package more portable, so that other developers can cut releases without having to globally install standard-version
on their machine.
bin
Install globally (add to your PATH
):
npm i -g standard-version
Now you can use standard-version
in place of npm version
.
This has the benefit of allowing you to use standard-version
on any repo/package without adding a dev dependency to each one.
npx
As of npm@5.2.0
, npx
is installed alongside npm
. Using npx
you can use standard-version
without having to keep a package.json
file by running: npx standard-version
.
This method is especially useful when using standard-version
in non-JavaScript projects.
You can configure standard-version
either by:
standard-version
stanza in your package.json
(assuming
your project is JavaScript)..versionrc
, .versionrc.json
or .versionrc.js
..versionrc.js
your default export must be a configuration object, or a function returning a configuration object.Any of the command line parameters accepted by standard-version
can instead
be provided via configuration. Please refer to the conventional-changelog-config-spec for details on available configuration options.
By default (as of 6.0.0
), standard-version
uses the conventionalcommits preset.
This preset:
There are a variety of dials and knobs you can turn related to CHANGELOG generation.
As an example, suppose you're using GitLab, rather than GitHub, you might modify the following variables:
commitUrlFormat
: the URL format of commit SHAs detected in commit messages.compareUrlFormat
: the URL format used to compare two tags.issueUrlFormat
: the URL format used to link to issues.Making these URLs match GitLab's format, rather than GitHub's.
NOTE: To pass nested configurations to the CLI without defining them in the
package.json
use dot notation as the parameterse.g. --skip.changelog
.
To generate your changelog for your first release, simply do:
# npm run script npm run release -- --first-release # global bin standard-version --first-release # npx npx standard-version --first-release
This will tag a release without bumping the version bumpFiles
1.
When you are ready, push the git tag and npm publish
your first release. \o/
If you typically use npm version
to cut a new release, do this instead:
# npm run script npm run release # or global bin standard-version
As long as your git commit messages are conventional and accurate, you no longer need to specify the semver type - and you get CHANGELOG generation for free! \o/
After you cut a release, you can push the new git tag and npm publish
(or npm publish --tag next
) when you're ready.
Use the flag --prerelease
to generate pre-releases:
Suppose the last version of your code is 1.0.0
, and your code to be committed has patched changes. Run:
# npm run script npm run release -- --prerelease
This will tag your version as: 1.0.1-0
.
If you want to name the pre-release, you specify the name via --prerelease <name>
.
For example, suppose your pre-release should contain the alpha
prefix:
# npm run script npm run release -- --prerelease alpha
This will tag the version as: 1.0.1-alpha.0
npm version
-like)To forgo the automated version bump use --release-as
with the argument major
, minor
or patch
.
Suppose the last version of your code is 1.0.0
, you've only landed fix:
commits, but
you would like your next release to be a minor
. Simply run the following:
# npm run script npm run release -- --release-as minor # Or npm run release -- --release-as 1.1.0
You will get version 1.1.0
rather than what would be the auto-generated version 1.0.1
.
NOTE: you can combine
--release-as
and--prerelease
to generate a release. This is useful when publishing experimental feature(s).
If you use git hooks, like pre-commit, to test your code before committing, you can prevent hooks from being verified during the commit step by passing the --no-verify
option:
# npm run script npm run release -- --no-verify # or global bin standard-version --no-verify
If you have your GPG key set up, add the --sign
or -s
flag to your standard-version
command.
standard-version
supports lifecycle scripts. These allow you to execute your
own supplementary commands during the release. The following
hooks are available and execute in the order documented:
prerelease
: executed before anything happens. If the prerelease
script returns a
non-zero exit code, versioning will be aborted, but it has no other effect on the
process.prebump
/postbump
: executed before and after the version is bumped. If the prebump
script returns a version #, it will be used rather than
the version calculated by standard-version
.prechangelog
/postchangelog
: executes before and after the CHANGELOG is generated.precommit
/postcommit
: called before and after the commit step.pretag
/posttag
: called before and after the tagging step.Simply add the following to your package.json to configure lifecycle scripts:
{ "standard-version": { "scripts": { "prebump": "echo 9.9.9" } } }
As an example to change from using GitHub to track your items to using your projects Jira use a
postchangelog
script to replace the url fragment containing 'https://github.com/`myproject`/issues/'
with a link to your Jira - assuming you have already installed replace
{ "standard-version": { "scripts": { "postchangelog": "replace 'https://github.com/myproject/issues/' 'https://myjira/browse/' CHANGELOG.md" } } }
You can skip any of the lifecycle steps (bump
, changelog
, commit
, tag
),
by adding the following to your package.json:
{ "standard-version": { "skip": { "changelog": true } } }
If you want to commit generated artifacts in the release commit, you can use the --commit-all
or -a
flag. You will need to stage the artifacts you want to commit, so your release
command could look like this:
{ "standard-version": { "scripts": { "prerelease": "webpack -p --bail && git add <file(s) to commit>" } } }
{ "scripts": { "release": "standard-version -a" } }
running standard-version
with the flag --dry-run
allows you to see what
commands would be run, without committing to git or updating files.
# npm run script npm run release -- --dry-run # or global bin standard-version --dry-run
Tags are prefixed with v
by default. If you would like to prefix your tags with something else, you can do so with the -t
flag.
standard-version -t @scope/package\@
This will prefix your tags to look something like @scope/package@2.0.0
If you do not want to have any tag prefix you can use the -t
flag and provide it with an empty string as value.
Note: simply -t or --tag-prefix without any value will fallback to the default 'v'
# npm run script npm run release -- --help # or global bin standard-version --help
const standardVersion = require('standard-version') // Options are the same as command line, except camelCase // standardVersion returns a Promise standardVersion({ noVerify: true, infile: 'docs/CHANGELOG.md', silent: true }).then(() => { // standard-version is done }).catch(err => { console.error(`standard-version failed with message: ${err.message}`) })
TIP: Use the silent
option to prevent standard-version
from printing to the console
.
standard-version
different from semantic-release
?semantic-release
is described as:
semantic-release automates the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.
While both are based on the same foundation of structured commit messages, standard-version
takes a different approach by handling versioning, changelog generation, and git tagging for you without automatic pushing (to GitHub) or publishing (to an npm registry). Use of standard-version
only affects your local git repo - it doesn't affect remote resources at all. After you run standard-version
, you can review your release state, correct mistakes and follow the release strategy that makes the most sense for your codebase.
We think they are both fantastic tools, and we encourage folks to use semantic-release
instead of standard-version
if it makes sense for their use-case.
The instructions to squash commits when merging pull requests assumes that one PR equals, at most, one feature or fix.
If you have multiple features or fixes landing in a single PR and each commit uses a structured message, then you can do a standard merge when accepting the PR. This will preserve the commit history from your branch after the merge.
Although this will allow each commit to be included as separate entries in your CHANGELOG, the entries will not be able to reference the PR that pulled the changes in because the preserved commit messages do not include the PR number.
For this reason, we recommend keeping the scope of each PR to one general feature or fix. In practice, this allows you to use unstructured commit messages when committing each little change and then squash them into a single commit with a structured message (referencing the PR number) once they have been reviewed and accepted.
standard-version
for additional metadata files, languages or version files?As of version 7.1.0
you can configure multiple bumpFiles
and packageFiles
.
bumpFile
"filename
", this is the path to the file you want to "bump"bumpFile
"updater
", this is how the file will be bumped.
a. If you're using a common type, you can use one of standard-version
's built-in updaters
by specifying a type
.
b. If your using an less-common version file, you can create your own updater
.// .versionrc { "bumpFiles": [ { "filename": "MY_VERSION_TRACKER.txt", // The `plain-text` updater assumes the file contents represents the version. "type": "plain-text" }, { "filename": "a/deep/package/dot/json/file/package.json", // The `json` updater assumes the version is available under a `version` key in the provided JSON document. "type": "json" }, { "filename": "VERSION_TRACKER.json", // See "Custom `updater`s" for more details. "updater": "standard-version-updater.js" } ] }
If using .versionrc.js
as your configuration file, the updater
may also be set as an object, rather than a path:
// .versionrc.js const tracker = { filename: 'VERSION_TRACKER.json', updater: require('./path/to/custom-version-updater') } module.exports = { bumpFiles: [tracker], packageFiles: [tracker] }
updater
sAn updater
is expected to be a Javascript module with atleast two methods exposed: readVersion
and writeVersion
.
readVersion(contents = string): string
This method is used to read the version from the provided file contents.
The return value is expected to be a semantic version string.
writeVersion(contents = string, version: string): string
This method is used to write the version to the provided contents.
The return value will be written directly (overwrite) to the provided file.
Let's assume our VERSION_TRACKER.json
has the following contents:
{ "tracker": { "package": { "version": "1.0.0" } } }
An acceptable
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景 。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号