Git-semver: Difference between revisions
No edit summary |
|||
Line 18: | Line 18: | ||
To commit MAJOR updates: | To commit MAJOR updates: | ||
[myrepo] git-sync --major Here is a major breaking change | [myrepo] git-sync --major Here is a major breaking change | ||
You can still do traditional git commits and pushes without using git-sync, if you don't want to add a tag. When you return to using git-sync, it will find the latest tag and increment it as expected. | |||
=== Publish node modules on commit === | === Publish node modules on commit === |
Latest revision as of 20:16, 8 December 2024
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
You can still do traditional git commits and pushes without using git-sync, if you don't want to add a tag. When you return to using git-sync, it will find the latest tag and increment it as expected.
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.