Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to skip version bumping. #251

Merged
merged 45 commits into from Feb 7, 2024

Conversation

tomfrenken
Copy link
Contributor

Hey all,

in our pipeline we already bumped the version of our package.json in a previous step, therefore we would like to skip bumping the version in this action.

This PR should introduce a simple option to do so.

@tomfrenken
Copy link
Contributor Author

Hey @TriPSs, do you think we could add this option? :)

@TriPSs
Copy link
Owner

TriPSs commented Feb 5, 2024

How different would this be than setting version file to an empty string?

@tomfrenken
Copy link
Contributor Author

tomfrenken commented Feb 5, 2024

Well, with an empty string we would cause the following error:

throw new Error(`File extension "${ext}" from file "${file}" is not supported`)

And even if we use skip-version-file and instead set a fallback-version to the one we actually want to use, the version is still bumped as is.

if (skipVersionFile || skipCommit) {
      core.info('Using GIT to determine the new version')
      const versioning = await handleVersioningByExtension( // this function bumps the version currently
        'git',
        versionFile,
        versionPath,
        recommendation.releaseType,
      )

@tomfrenken
Copy link
Contributor Author

I just added another conditional to set the newVersion to the oldVersion, as the newVersion property was only set when you are bumping (which we are trying not to do), and then later on this property is used for the changelog generation and therefore necessary.

Copy link
Owner

@TriPSs TriPSs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I find it a bit weird I do not see any harm in support things, could you do the following:

  1. Commit to this repo following conventional commits
  2. Process comments
  3. Add tests

src/index.js Show resolved Hide resolved
@tomfrenken
Copy link
Contributor Author

tomfrenken commented Feb 5, 2024

Thanks for the review, it wasn't entirely clear to me how all the testing in this repo behaves, but I believe my implementation should test it properly according to the existing standards.

Regarding your first point:

Commit to this repo following conventional commits

I did create the PR with a conventional commit message and would usually squash merge & remove all commit messages while squashing, would that work for you, or how exactly should I proceed?

@tomfrenken
Copy link
Contributor Author

tomfrenken commented Feb 5, 2024

Also please approve the workflow run again :)

@TriPSs
Copy link
Owner

TriPSs commented Feb 5, 2024

I did create the PR with a conventional commit message and would usually squash merge & remove all commit messages while squashing, would that work for you, or how exactly should I proceed?

We could do that, regarding the test: should the tag it creates not be the same as the version in the file?

@TriPSs
Copy link
Owner

TriPSs commented Feb 5, 2024

The test is also failing, it's creating a tag with vnull now

@tomfrenken
Copy link
Contributor Author

Indeed, both the test and the implementation need some changes, currently the old version is only loaded after using the bump function, I'll make some more changes.

@tomfrenken
Copy link
Contributor Author

Alright, I've adjusted the test as per your suggestion and also changed the classes to use a proper constructor instead of the init method, now the files are read and parsed at initialization, this way the oldVersion is accessible independently of bumping.

@TriPSs
Copy link
Owner

TriPSs commented Feb 6, 2024

@tomfrenken you can also run the actions locally, see the README. My preference would be to only implement your feature here and leave existing code more as is (So keep the init, as I prefer to only pass args once and not for each class separate).

@tomfrenken
Copy link
Contributor Author

@TriPSs thanks for the abstract method suggestion, great idea.
I've implemented the change and also added additional tests for corner cases.

@tomfrenken tomfrenken changed the title feature: Add option to skip version bumping. feat: Add option to skip version bumping. Feb 6, 2024
Copy link
Owner

@TriPSs TriPSs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks already for your work!

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/version/json.js Outdated Show resolved Hide resolved
@tomfrenken
Copy link
Contributor Author

Awesome, moving the logic to the version function also removed the code duplication, and the improved conditional logic is also way cleaner.

@TriPSs TriPSs merged commit 17fb98e into TriPSs:releases/v5 Feb 7, 2024
@TriPSs
Copy link
Owner

TriPSs commented Feb 7, 2024

Thanks for the PR 🎉

@tomfrenken
Copy link
Contributor Author

Thanks for the quick reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants