Reference current component version in the template

I’m experimenting with CI/CD components and have stumbled upon a versioning problem.

I would like to put a custom builder image and a template referencing that image in the same repository. This works more or less perfectly with main branch, i.e.

Project’s .gitlab-ci.yml:

include:
  - component: mygitlab.com/group/project@main

Component template:

job:
  image: "registry.mygitlab.com/group/project:main"

However, if I release this component, I would like to reference the tagged version of the image inside the component, which I see no obvious way to do:

Project’s .gitlab-ci.yml:

include:
  - component: mygitlab.com/group/project@0.0.1

Component template:

job:
  image: "registry.mygitlab.com/group/project:???"

What are my options here?

Thanks for the idea. I’ve asked our engineers whether it is possible to extract the tagged component version into a “local” input to being reused for specifying container image tags.

The feature request is tracked in Allow interpolation to use local context data (#438275) · Issues · GitLab.org / GitLab · GitLab and might be solved with this proposal. Suggest subscribing and commenting there. I have linked this forum topic there, too.

Thanks! Will be keeping an eye on it.