This might sound weird, but is there a way to make drone create a new
git tag every time a build is successful?
I saw a lot of tagging for the docker image, but was wondering if this can be possible
This might sound weird, but is there a way to make drone create a new git tag every time a build is successful?
Yes, you can execute a git tag and push directly from your commands section (see below)
pipeline: build: ... tag: image: docker:git # this image has git installed commands: - git tag vX.Y.Z - git push origin vX.Y.Z
Note that if your repository is public, you will need to provide a way to authenticate the git+https push. This can be done creating a drone secret  that includes a username/password or oauth token that you can provide to the git command.
I saw a lot of tagging for the docker image
This tagging is being performed by a plugin, which is essentially just executing shell commands under the covers . You could encapsulate the above shell commands in a plugin, if you really wanted.
Thanks for the quick response.
Sorry, what I tried to say is that I searched for how to do tagging, but all the searches was regarding docker tagging and not what I hoped to find out.
I will try to see if I can manage to use that.
Since it’s very common to perform docker tags, another quick question would be is it recommended what I am trying to accomplish or would the docker tagging suffice?
Sorry, I’m not sure I understand the question, since Docker tagging and git tagging are separate things. If you want to push a git tag to your remote, I do not believe the Docker plugin is relevant here. The Docker plugin is used to build, tag and push Docker images to Dockerhub, which is a different use case.
Yeah, sorry for the confusion.
Managed to perform the tagging successfully with the provided steps.
Thanks a lot. Have a good one!
I’d like to follow up on this discussion. The method suggested by @bradrydzewski utilizes
git tag vX.Y.Z. Is there a clean way to increment the
Z part in the tag? I though of using
DRONE_BUILD_NUMBER mentioned here, but I don’t know how to connect the wires correctly.
FWIW: I might be using something like:
- name: git-tag image: docker:git commands: - export EMR_UTILS_VER_FOR_GIT=$(cat my_pkg/_version.py | sed 's/__version__ = "/v/g' | sed 's/"//g') - echo $EMR_UTILS_VER_FOR_GIT - git tag $EMR_UTILS_VER_FOR_GIT - git push origin $EMR_UTILS_VER_FOR_GIT when: event: push branch: master
my_pkg/_version.py is assumed to be something like:
__version__ = "0.1.6"
Comments and feedbacks would be appreciated!
@bradrydzewski how should I use your suggestion, namely the tag step?
+ git tag 327ed6dd + git push origin 327ed6dd fatal: could not read Username for 'https:/example.com': terminal prompts disabled