Git-semver

From Bitpost wiki
Revision as of 20:14, 8 December 2024 by M (talk | contribs)

GitSemver.png ou

Intro

This tooling is essential to every hour of my streamlined development flow. See the project README for more.

Gitlab

Github

Npm

Strategies

Generate a semantic version on every commit

This is the git-sync standard behavior. To commit patches:

[myrepo] git-sync Here is a patch with bug fixes

To commit MINOR updates:

[myrepo] git-sync --minor Here is a minor update that adds functionality

To commit MAJOR updates:

[myrepo] git-sync --major Here is a major breaking change

Publish node modules on commit

First, import git-semver into your node module.

npm install --save @moodboom/git-semver

Then you can create a sync function that will publish your module. I recommend cloning my cloudflare-sync-dns module and using that as a template.

You will be writing a stamp function that will publish the module with each new version, and a sync command to trigger it on commits, eg:

[mymodule] mymodule sync Here is a patch with bug fixes

If you don't want to publish every time you commit, you can use the more generic git-sync, which will not call the stamp function that publishes the module (but will properly increment version in git tags):

[mymodule] git-sync Here is another patch

Then when ready to publish, use the stamp function.

You can still manually publish your module if you need; the next git-semver version will adjust.

You can manually hack a new higher version into package.json. git-sync will find it, and increment the next semantic version to be one patch higher.