mirror of https://github.com/astral-sh/uv
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
This commit is contained in:
parent
17181fef07
commit
d283f03b13
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue