Git-semver: Difference between revisions

From Bitpost wiki
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:GitSync.png]]
[[File:GitSemver.png]]
 
ou
== Intro ==
This tooling is essential to every hour of my streamlined development flow.  See the project README for more.
This tooling is essential to every hour of my streamlined development flow.  See the project README for more.


Line 8: Line 9:


=== [https://www.npmjs.com/package/git-sync Npm] ===
=== [https://www.npmjs.com/package/git-sync 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 [https://gitlab.com/moodboom/cloudflare-sync-dns 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.

Latest revision as of 20:16, 8 December 2024

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

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.