Skip to content

Instantly share code, notes, and snippets.

@montasim
Created July 6, 2024 14:22
Show Gist options
  • Save montasim/3b3d21c6689cdc1e1af93b3bd916e349 to your computer and use it in GitHub Desktop.
Save montasim/3b3d21c6689cdc1e1af93b3bd916e349 to your computer and use it in GitHub Desktop.
Using a .versionrc.json file: Automates Version Management: Automatically handles version increments based on commit types and messages, ensuring consistent versioning that adheres to semantic versioning principles. Streamlines Releases: Simplifies the process of generating changelogs and tagging releases, saving time and reducing human error. E…
{
"types": [
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "chore",
"section": "Chores",
"hidden": true
},
{
"type": "docs",
"section": "Documentation",
"hidden": false
},
{
"type": "style",
"section": "Styles",
"hidden": true
},
{
"type": "refactor",
"section": "Code Refactoring",
"hidden": false
},
{
"type": "perf",
"section": "Performance Improvements",
"hidden": false
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System",
"hidden": false
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": false
}
],
"branch": "main",
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"releaseCommitMessageFormat": "chore(release): release {{currentTag}}",
"skip": {
"bump": false,
"changelog": false,
"commit": false,
"tag": false
},
"scripts": {
"precommit": "yarn test",
"postchangelog": "echo 'Remember to push tags with git push --follow-tags' && yarn build"
}
}
@montasim
Copy link
Author

montasim commented Jul 6, 2024

Configuration Overview

.versionrc.json specifies how version bumps are calculated, how the changelog is formatted, and what types of commits trigger which kind of version changes. It’s designed to streamline release processes by ensuring that all changes to the codebase are documented and versioned in a standardized way.

Configuration Options

"types": Defines how different types of commits are displayed in the changelog or if they are included at all:

"feat": Commits that introduce new features. These are included under the "Features" section in the changelog.
"fix": Commits that fix bugs. These appear under "Bug Fixes."
"chore": Routine tasks or maintenance commits. These are hidden from the changelog.
"docs": Documentation-related changes are shown under "Documentation."
"style": Changes that do not affect the code logic (formatting, missing semi-colons, etc.) and are hidden.
"refactor": Code changes that neither fix a bug nor add a feature, shown under "Code Refactoring."
"perf": Improvements that enhance performance, listed under "Performance Improvements."
"test": Adding or correcting tests, hidden from the changelog.
"build": Changes to build processes or auxiliary tools and libraries such as documentation generation, under "Build System."
"ci": Changes to CI configuration files and scripts, included under "Continuous Integration."
"branch": The primary branch for releases, typically "main" or "master."

"commitUrlFormat", "compareUrlFormat", "issueUrlFormat": URL templates for linking to commits, comparing code between tags, and linking to issues, respectively. These are templated to use with your project's repository URL structure.

"releaseCommitMessageFormat": Specifies the format of the commit message for a release, e.g., chore(release): release {{currentTag}}.

"skip": Options to skip certain steps during the release process, such as bumping versions, generating changelogs, committing changes, or tagging.

"scripts": Custom scripts to run at specified stages of the release process:

"precommit": Runs before a commit is made, such as running tests.
"postchangelog": Runs after the changelog is generated, typically used for tasks like building the project or reminders to push tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment