I have a stage in .gitlab-ci.yaml aimed to increase my python project version.
version_up_for_dev:
only:
- development
stage: Bump Version
script:
- poetry version prepatch
- PROJECT_VERSION=$(poetry version | awk '{ print $2 }')
- git commit -m "[CICD] bump version for Development to $PROJECT_VERSION" pyproject.toml
- git tag -a v$PROJECT_VERSION -m "[CICD] version $PROJECT_VERSION"
- git push --atomic origin HEAD:${CI_COMMIT_REF_NAME} v$PROJECT_VERSION -o ci.skip
After one run tag was created inside the runner version of a remote repository, but git push command failed. Consequently, in the origin repository there no tag v$PROJECT_VERSION, but now each time CICD pipeline is triggered runner sees tag v$PROJECT_VERSION inside it version of the repo, so it’s impossible to successfully execute command git tag -a v$PROJECT_VERSION since the tag already exists.
When I run git log --graph --decorate --oneline --all inside runner container I can see that tagging is presented in the history.
But there no such commits in remote repo!
What’s the correct way to do tagging and additional commits inside runners?
I’m using GitLab Community Edition [13.7.6].