I'm migrating from the classic yarn to version 4 and encountered an issue with my version bump CI job since the --no-commit-hooks and --no-git-tag-version flags are not there anymore with the modern yarn versions.
This is a part of the Gitlab CI job I use for bumping the version (using the classic yarn):
script:
- ... some preparing scripts
- git tag -a v$APP_VERSION -m "v$APP_VERSION"
- yarn version --patch --no-commit-hooks --no-git-tag-version
- git pull origin $CI_COMMIT_REF_NAME -X theirs --no-commit && git commit -a -m "chore(release): v$APP_VERSION"
- git push -o ci.skip --tags origin HEAD:$CI_COMMIT_REF_NAME
To break it down:
- We're skipping the git hooks (to avoid issues with Husky and other precommit tools)
- we're creating the tag with the existing (pre-version) package.json version
- and we're modifying the commit message to be in the expected format.
What would be the alternative way of doing this with yarn v4?
I've been going through the yarn documentation, but the version CLI docs are showing that the command has only some basic configuration options. I've also opened an discussion in the berry repo, but no responses so far.
So, it looks like I've been looking for replacements for the above hooks but haven't tested the behavior of the
yarn version.yarn versionbumps the version but doesn't create a tag or commit, so that's nice. It also runs theyarn install, which is not nice. In the end, the following piece of code can replace the configuration I've been using for yarn classic:Using
no-verifyto skip running git hooks. It would be nice to preventyarn installas well, but I couldn't find a solution for that, and there is an unanswered discussion for the same issue: https://github.com/yarnpkg/berry/discussions/4551.