Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Computer Resources
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IMGW
Computer Resources
Merge requests
!9
Haslwantem99 master patch 41307
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Haslwantem99 master patch 41307
haslwantem99-master-patch-41307
into
master
Overview
1
Commits
22
Pipelines
0
Changes
3
Merged
Emma Haslwanter
requested to merge
haslwantem99-master-patch-41307
into
master
2 months ago
Overview
1
Commits
22
Pipelines
0
Changes
3
Added explanation on how to use a pipeline to build an publish a python package
0
0
Merge request reports
Compare
master
version 11
606acd86
3 weeks ago
version 10
58edbfca
3 weeks ago
version 9
f00967be
3 weeks ago
version 8
f00967be
3 weeks ago
version 7
ff0885ca
3 weeks ago
version 6
afcef0f0
3 weeks ago
version 5
35d07c4c
3 weeks ago
version 4
377c14a9
3 weeks ago
version 3
2f123256
3 weeks ago
version 2
bed542e1
3 weeks ago
version 1
d2134aac
2 months ago
master (base)
and
latest version
latest version
606acd86
22 commits,
3 weeks ago
version 11
606acd86
22 commits,
3 weeks ago
version 10
58edbfca
21 commits,
3 weeks ago
version 9
f00967be
20 commits,
3 weeks ago
version 8
f00967be
20 commits,
3 weeks ago
version 7
ff0885ca
19 commits,
3 weeks ago
version 6
afcef0f0
18 commits,
3 weeks ago
version 5
35d07c4c
17 commits,
3 weeks ago
version 4
377c14a9
16 commits,
3 weeks ago
version 3
2f123256
15 commits,
3 weeks ago
version 2
bed542e1
14 commits,
3 weeks ago
version 1
d2134aac
5 commits,
2 months ago
3 files
+
158
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Python/QA-015-Using Pipelines for building.md
0 → 100644
+
55
−
0
View file @ 606acd86
Edit in single-file editor
Open in Web IDE
# Using a Gitlab pipeline for building and publishing a python package
## Steps
## 1. Prepare Your Python Package
Ensure your Python package is properly structured and includes the following:
A pyproject.toml file for package configuration.
A README.md file for documentation.
## 2. Create a .gitlab-ci.yml File
This file defines the pipeline stages and jobs. Below is an example .gitlab-ci.yml for building and publishing a Python package:
```
sh
default:
image: python:3.13
cache:
paths:
- .pip-cache/
before_script:
- python
--version
- pip
install
--upgrade
pip
- pip
install
build twine
stages:
- build
- publish
variables:
PIP_CACHE_DIR:
"
$CI_PROJECT_DIR
/.pip-cache"
build:
stage: build
script:
- python
-m
build
artifacts:
paths:
- dist/
publish:
stage: publish
script:
-
TWINE_PASSWORD
=
${
CI_JOB_TOKEN
}
TWINE_USERNAME
=
gitlab-ci-token python
-m
twine upload
--repository-url
${
CI_API_V4_URL
}
/projects/
${
CI_PROJECT_ID
}
/packages/pypi dist/
*
rules:
-
if
:
$CI_COMMIT_TAG
```
## 3.Push Your Code and Tags
Push your code to the GitLab repository.
To trigger the publish stage, create and push a tag
\ No newline at end of file
Loading