Socket
Socket
Sign inDemoInstall

@cp-utils/gitversion

Package Overview
Dependencies
246
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @cp-utils/gitversion

Gitversion is a complete customizable git-based release management system


Version published
Weekly downloads
124
decreased by-47.23%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

Gitversion

Gitversion is a complete customizable git-based release management system. Primarily focused on package releases.

NPM Version

Key concepts

  • Branch based release strategy
  • Tag based versioning (no versions in files)
  • Conventional commit based bumps
  • Native monorepo support
  • Split stage publish
  • Plugin based customization

How does it work

Branch based release strategy

The core concept of gitversion evolves around branch detection and branch types.

Gitversion defines the following types:

  • main/master branch (default branch name 'main')
  • release branches (default matches 'release/*')
  • feature branches (default matches 'feature/*')

The names and detections can be customized to your own need.

Depending on the detected branch types the system will make different choices:

BranchBranch typeVersion namings(NPM) Release tagChangelogNotes
mainmain1.0.0latestyesOfficial releases
release/nextrelease1.0.0‑next.0nextyes(Pre) releases
feature/gh‑1234feature1.0.0‑gh‑1234.0gh‑1234 (*)noFeature release. I.e. to let the customer test the requested feature

You can chose if and how feature releases are released. This can differ from release branches.

Tag based versioning

Like most release systems gitversion will add a tag for each release. This will follow the tag naming with a prefix (default 'v'). I.e.

  • v1.0.0
  • v1.2.3-next.0

The difference of gitversion is that the tags are the only source of truth. It does not care about versions inside files and will keep them even on the default "0.0.0".

There are two main advantages of this strategy:

  • One source of truth. Easy to see in git history what the current state is
  • No more merge conflicts due to mismatches of versions. Otherwise this will happen constantly with feature/release strategies

Gitversion has 2 commands to work with this git-only version strategy:

Restore
yarn gitversion restore

The output will be something like:

gitversion restore

As you see with this you wil get all versions back in package.json files.

Reset
yarn gitversion reset

The output will be something like:

gitversion reset

As you see with this you wil reset all versions back to '0.0.0'.

Conventional commit based bumps

Gitversion works with the concept of a "bump". This is one of the key commands:

yarn gitversion bump

Bump will do the following steps:

  • Restore the current status from git
  • Read the git history and search for Conventional commit style messages
  • Define a bump type based on the outcome
  • Update the workspaces with the new version
  • Udate the workspaces with the workspace specific changelogs
  • Create a bump manifest in the gitversion.out folder containing versions and changelogs

Native monorepo support

Gitversion is build for monorepos with multiple workspaces. It will detect all (public) workspaces and use them during bump.

There are 2 main operation modes:

Global versioning

This is the default mode. This will keep all versions of all workspaces the same. This is useful for monorepos with series of packages (i.e. '@aws-sdk/'*)

Independent versioning

This will use unique versions per workspace in the mono repo. Based on the path of the committed files it will decide if the specific workspace needs a bump and which bump type.

Split stage publish

Gitversion is buld for usage within CI/CD pipelines. When building packages gitversion can be used in a pipeline like this:

Pipeline

This will allow you to run your time consuming steps in parallel with your build step. Only when all checks pass you have a (quick) publish stage.

Keywords

FAQs

Last updated on 29 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc