Semantic Versioning for every pipeline

I am planning to migrate my pipelines from Azure DevOps to Gitlab. I want to implement semantic versioning. I tried to few ways but it didn’t work. I tried writing githooks and versioning is generating as expected but I am not able to update the tag with latest version. I used below command to update,

git tag “$newVersion”

git push origin "$newVersion"
git tag -a -m "Update version to $VERSION" Version "$newVersion"

git push -uf origin main

but no use.
i want to implement semantic versioning in gitlab ci pipeline. for every pipeline run it should display the vesion as below,

1.0.0, 1.0.1, 1.0.2, 1.0.3 and so on