AlexKVal/release-script

Skip Version Bump

Closed this issue ยท 11 comments

It would be cool if there was a way to skip version bumping. Use case:

  • Initial commit of repo: make version in package.json 0.0.1 or similar
  • release major --run to bump package to version 1.0.0 and release it

I accidentally committed a package.json with a version of 1.0.0, so I either need to do a patch version bump to 1.0.1 (not ideal) or recreate the repository with an arbitrary pre-1.0.0 version number.

I did this mistake in the past too.

These two commands

> release --preid=pre
> release patch

solved it.

In result the version remains the same and all is published.
After release --preid I did git add . && git commit with that message:
[fixed] accidental manual version change

This use case is happening very rare ๐Ÿ˜‰ Do you agree ?

These two commands

release --preid=pre
release patch

solved it.

In result the version remains the same and all is published.
After release --preid I did git add . && git commit with that message:
[fixed] accidental manual version change

That's one way of handling it. Another way would be to manually change the version in package.json and commit, then run release. Both methods result in an unnecessary commit though, and it would be cool if that could be avoided.

This use case is happening very rare ๐Ÿ˜‰ Do you agree ?

I've actually made this mistake more than once ๐Ÿ˜. Usually I just delete the repo, recreate it, commit with an arbitrary pre-1.0.0 version number, and run release major.

Then I propose the same as in #33 (comment)

I will help you of course if you decide to make a PR. ๐Ÿ’

@mjhasbach 4862716?w=1 ๐Ÿ˜‰
v0.5.7 has been released โ‡๏ธ

Awesome thanks!

I just tried this today and ran into a problem:

release --skip-version-bumping --run
No pending changes
Current with latest changes from remote
The version remains the same 1.0.0
Running: "npm run test"
Completed: "npm run test"
Skipping "npm run build" step.
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

That Git error caused release-script to exit.

Yep. As usually with edge cases ๐Ÿ˜‰ something additional pops up.
There has to be at least something to commit.
Usually it is either changed package.json or CHANGELOG.md.

This is the main reason of releasing process - to release something new ๐Ÿ˜„
Otherwise it would be possible to publish the same codebase w/o changes at all again and again.

Nothing comes to my head for now what is the best way to deal with such situations.

I feel that the ability to run release without changing anything has value (e.g. the initial repo commit example mentioned earlier). In those cases, I think it would be appropriate to skip the Git commit / push steps and proceed with Git tagging, NPM releasing, etc.

A problem from another side of coin could arise with it.
Other users could expect that release-script does nothing if there are no changes ๐Ÿ˜„
It should be taken into account too. Do you agree ?

I came across with similar issue with the default run mode:
dry or real #19

Other users could expect that release-script does nothing if there are no changes

Yes, in that case, I feel that a prompt would be appropriate:

No changes detected. Would you like to release the package anyway? y/N

Another approach would be to check if the package has ever been published to NPM or if the repo has any tags.

It sounds like a possible solution ๐Ÿ‘