1

I would like to bump the package.json version variable on every push:

  • 0.1.0 => 0.1.1 (for example)

My project uses Yarn thus I stumbled across the following command:

  • yarn version --patch --no-git-tag-version

This does indeed bump the version how I expect, but only affects the local cached package.json file and not the package.json file on the actual repository:

updates cached package.json

My question is therefore, how can I bump the package.json version variable on the actual GitLab repository through CI/CD pipelines?

Dainank
  • 2,142
  • 2
  • 7
  • 14

1 Answers1

1

You are doing it good, but you need to commit the new version. You can do it by keeping the tag and it will automatically be committed :

$ yarn version --patch
yarn version v1.22.5
info Current version: 0.1.0
info New version: 0.1.1
Done in 0.08s.

$ git log --oneline
c8211a0 (tag: v0.1.1) v0.1.1

Or you just need to commit after changing the version :

$ yarn version --patch --no-git-tag-version
yarn version v1.22.5
info Current version: 0.1.0
info New version: 0.1.1
Done in 0.06s.

$ git commit -am "Bump version"

$ git log --oneline
944ee64 (HEAD -> main) Bump version

Then you have to push to the repository, see Cannot push from gitlab-ci.yml.

fmdaboville
  • 1,394
  • 3
  • 15
  • 28