Skip to content

Instantly share code, notes, and snippets.

@AKuederle
Created August 29, 2025 10:19
Show Gist options
  • Save AKuederle/4169a38e61292e66a6ab756f735fb4e5 to your computer and use it in GitHub Desktop.
Save AKuederle/4169a38e61292e66a6ab756f735fb4e5 to your computer and use it in GitHub Desktop.
Minimal example to publish Python package to Gitlab index using uv
```yaml [.gitlab-ci.yml]
stages:
- deploy
variables:
UV_VERSION: "0.8"
PYTHON_VERSION: "3.10"
BASE_LAYER: bookworm-slim
# GitLab CI creates a separate mountpoint for the build directory,
# so we need to copy instead of using hard links.
UV_LINK_MODE: copy
UV_CACHE_DIR: .uv-cache
# Gitlab Registry
UV_PUBLISH_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi/
UV_PUBLISH_USERNAME: gitlab-ci-token
UV_PUBLISH_PASSWORD: ${CI_JOB_TOKEN}
.uv_base:
image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
cache:
- key:
files:
- uv.lock
- paths:
- $UV_CACHE_DIR
after_script:
- uv cache prune --ci
publish:
stage: deploy
rules:
- if: $CI_COMMIT_TAG # Run for all tagged commits
extends: .uv_base
script:
- uv build
- uv publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment