diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml
index c125701ca5b2b16ebdad88b8d98521e1bedf6bd5..eb11f2df15f186edbae8d9561dda711ec9cd1d06 100644
--- a/templates/gitlab-ci-python.yml
+++ b/templates/gitlab-ci-python.yml
@@ -504,7 +504,7 @@ variables:
 
     # 3: Git commit, tag and push
     log_info "--- git push commit and tag..."
-    git push "$git_auth_url" "$CI_BUILD_REF_NAME"
+    git push "$git_auth_url" "$CI_COMMIT_REF_NAME"
     git push "$git_auth_url" --tags
 
     # 4: build new version distribution
@@ -844,7 +844,7 @@ py-release:
   script:
     - git config --global user.email "$GITLAB_USER_EMAIL"
     - git config --global user.name "$GITLAB_USER_LOGIN"
-    - git checkout -B $CI_BUILD_REF_NAME
+    - git checkout -B $CI_COMMIT_REF_NAME
     - configure_scm_auth
     - _release
   artifacts: