diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 00446c8dde9cbf9cf8ee8d06a858cd99cd3b12cd..659edee4889ef30d9d97c654e3557405e5aafe2b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -14,12 +14,10 @@ variables:
   PIP_INDEX_URL: "https://__token__:${CI_JOB_TOKEN}@gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/pypi/simple"
   PIP_EXTRA_INDEX_URL: "https://pypi.org/simple"
 
-before_script:
-  - pip install setuptools wheel build twine
-
 build_package:
   stage: build
   script:
+    - pip install setuptools wheel build twine
     - python -m build
   artifacts:
     paths:
@@ -32,11 +30,10 @@ test_package:
     - pip install pytest
     - pytest  # Run tests
 
-publish_package:
+publish_pip:
   stage: publish
   script:
-    - pip install twine  # Install twine to publish the package
-    - twine upload dist/*  # Publish the package to the GitLab package registry
+    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
 
 build_and_push_docker_image:
   stage: publish