From d283f03b1347304c9d45cec2fed7bc8266fab51e Mon Sep 17 00:00:00 2001 From: Julian Krauth Date: Fri, 24 Oct 2025 09:24:46 +0200 Subject: [PATCH 1/4] Add GitLab release job example Add example of a GitLab release job to the integration docs: - Publish to GitLab PyPI registry - Create a release item - Link wheel files in PyPI registry to the release using assets-links --- docs/guides/integration/gitlab.md | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/guides/integration/gitlab.md b/docs/guides/integration/gitlab.md index 0a4073394..53ea6a5d0 100644 --- a/docs/guides/integration/gitlab.md +++ b/docs/guides/integration/gitlab.md @@ -84,3 +84,38 @@ To opt-out again, the `--no-system` flag can be used in any uv invocation. When persisting the cache, you may want to use `requirements.txt` or `pyproject.toml` as your cache key files instead of `uv.lock`. + +## Publishing to the GitLab PyPI index + +`uv publish` can be used to publish to the GitLab PyPI registry, but it will not update your release with corresponding assets links to the uploaded wheel files. It also does not provide assets links as they would be required by `glab release create --assets-links` to connect the wheel files with their corresponding release item. + +The following example of a release job, triggered by a pushed tag, will publish all wheel files in the GitLab PyPI registry of the project and create assets links for the corresponding release item. + +```yaml title="gitlab-ci.yml" +release-job: + stage: release + rules: + - if: $CI_COMMIT_TAG + variables: + GLAB_CHECK_UPDATE: 'no' + 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}" + script: + - uv build --wheel --all-packages + release: + tag_name: '$CI_COMMIT_TAG' + description: '$CI_PROJECT_NAME release $CI_COMMIT_TAG' + after_script: + - | + for package in dist/*.whl; do + uv publish "$package" && \ + GITLAB_HOST=$CI_SERVER_URL glab release create "$CI_COMMIT_TAG" \ + --repo "$CI_PROJECT_PATH" \ + --assets-links='[{"name": "'$(basename "${package%-*-*-*}")'", + "url": "'"$UV_PUBLISH_URL/files/$(sha256sum "$package" | cut --delimiter=' ' --fields=1)/$(basename "$package")"'", + "link_type": "package"}]' + done +``` + +The items in the PyPI registry of the GitLab project will also be available via the PyPI registry of the corresponding GitLab group. From 5f73599048421893855ae9b6a26c27625e935c7e Mon Sep 17 00:00:00 2001 From: Julian Krauth Date: Mon, 27 Oct 2025 10:33:44 +0100 Subject: [PATCH 2/4] Fix indentation alignment --- docs/guides/integration/gitlab.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/integration/gitlab.md b/docs/guides/integration/gitlab.md index 53ea6a5d0..a6c4b437c 100644 --- a/docs/guides/integration/gitlab.md +++ b/docs/guides/integration/gitlab.md @@ -113,8 +113,8 @@ release-job: GITLAB_HOST=$CI_SERVER_URL glab release create "$CI_COMMIT_TAG" \ --repo "$CI_PROJECT_PATH" \ --assets-links='[{"name": "'$(basename "${package%-*-*-*}")'", - "url": "'"$UV_PUBLISH_URL/files/$(sha256sum "$package" | cut --delimiter=' ' --fields=1)/$(basename "$package")"'", - "link_type": "package"}]' + "url": "'"$UV_PUBLISH_URL/files/$(sha256sum "$package" | cut --delimiter=' ' --fields=1)/$(basename "$package")"'", + "link_type": "package"}]' done ``` From f569039ba54039363a33da46c499d05e57cfab01 Mon Sep 17 00:00:00 2001 From: Julian Krauth Date: Mon, 27 Oct 2025 10:54:27 +0100 Subject: [PATCH 3/4] Add note about package request forwarding behaviour --- docs/guides/integration/gitlab.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guides/integration/gitlab.md b/docs/guides/integration/gitlab.md index a6c4b437c..9a5febef0 100644 --- a/docs/guides/integration/gitlab.md +++ b/docs/guides/integration/gitlab.md @@ -119,3 +119,5 @@ release-job: ``` The items in the PyPI registry of the GitLab project will also be available via the PyPI registry of the corresponding GitLab group. + +Note also the [package request forwarding behaviour](https://docs.gitlab.com/user/packages/pypi_repository/#package-request-forwarding-security-notice) of GitLab, which might forward your request automatically to `pypi.org`, even when using the `--default-index` flag. From 9575b29b33c63d3bc820cdd04a4e0817a07f32dc Mon Sep 17 00:00:00 2001 From: Julian Krauth Date: Mon, 27 Oct 2025 11:01:46 +0100 Subject: [PATCH 4/4] Wrap md lines of added content to max 80 characters --- docs/guides/integration/gitlab.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/guides/integration/gitlab.md b/docs/guides/integration/gitlab.md index 9a5febef0..7407353c5 100644 --- a/docs/guides/integration/gitlab.md +++ b/docs/guides/integration/gitlab.md @@ -87,9 +87,15 @@ your cache key files instead of `uv.lock`. ## Publishing to the GitLab PyPI index -`uv publish` can be used to publish to the GitLab PyPI registry, but it will not update your release with corresponding assets links to the uploaded wheel files. It also does not provide assets links as they would be required by `glab release create --assets-links` to connect the wheel files with their corresponding release item. +`uv publish` can be used to publish to the GitLab PyPI registry, but it will +not update your release with corresponding assets links to the uploaded wheel +files. It also does not provide assets links as they would be required by +`glab release create --assets-links` to connect the wheel files with their +corresponding release item. -The following example of a release job, triggered by a pushed tag, will publish all wheel files in the GitLab PyPI registry of the project and create assets links for the corresponding release item. +The following example of a release job, triggered by a pushed tag, will publish +all wheel files in the GitLab PyPI registry of the project and create assets +links for the corresponding release item. ```yaml title="gitlab-ci.yml" release-job: @@ -118,6 +124,9 @@ release-job: done ``` -The items in the PyPI registry of the GitLab project will also be available via the PyPI registry of the corresponding GitLab group. +The items in the PyPI registry of the GitLab project will also be available via +the PyPI registry of the corresponding GitLab group. -Note also the [package request forwarding behaviour](https://docs.gitlab.com/user/packages/pypi_repository/#package-request-forwarding-security-notice) of GitLab, which might forward your request automatically to `pypi.org`, even when using the `--default-index` flag. +Note also the [package request forwarding behaviour](https://docs.gitlab.com/user/packages/pypi_repository/#package-request-forwarding-security-notice) +of GitLab, which might forward your request automatically to `pypi.org`, even +when using the `--default-index` flag.