Skip to content
Snippets Groups Projects
Commit ce234998 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Merge branch 'feature/mad-91-gitlab-pipeline' into 'main'

Feature/mad 91 gitlab pipeline

See merge request !1
parents 8f71f78c a332e8d1
No related branches found
No related tags found
1 merge request!1Feature/mad 91 gitlab pipeline
Pipeline #710 failed
default:
image: python:3.10
stages:
- build
- test
- deploy
before_script:
- python -V
- python -m venv venv
- . venv/bin/activate
- pip install --upgrade pip
- pip install -e .
build:
stage: build
tags:
- vips-runner
script:
- pip install build
- python -m build
artifacts:
paths:
- dist/*.whl
expire_in: 2 days
test:
stage: test
tags:
- vips-runner
script:
- pip install pytest
- pytest
deploy:
stage: deploy
only:
- main
tags:
- vips-runner
script:
- pip install twine
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url https://gitlab.nibio.no/api/v4/projects/401/packages/pypi dist/* --verbose
......@@ -44,4 +44,45 @@ bumpver update --major
[(Source)](https://semver.org/#summary)
### References
We used this excellent guide for packaging: https://realpython.com/pypi-publish-python-package/
\ No newline at end of file
We used this excellent guide for packaging: https://realpython.com/pypi-publish-python-package/
### Deployment
Whenever changes are pushed to the repository, the pipeline defined in `.gitlab-ci.yml` is triggered. Here, there are three jobs: build, test and deploy.
The final job will only be performed for the `main` branch. Please note that publishing a package to the package repository will fail (= red deploy job)
if the version of the package has not been bumped since the previous deploy.
Follow these steps for running build, test + deploy on your laptop:
1. Create [Personal access token](https://gitlab.nibio.no/-/profile/personal_access_tokens) with name=`gitlab-pypi` and scope=`Api`.
2. Create file `~/.pypirc` with the following content:
```
[distutils]
index-servers =
gitlab
[gitlab]
repository = https://gitlab.nibio.no/api/v4/projects/401/packages/pypi
username = gitlab-pypi
password = <personal access token>
```
3. Clone project, build, test and deploy package
```
$ git clone git@gitlab.nibio.no:VIPS/vipscore-python-common.git
$ cd vipscore-python-common
$ python3 -m venv venv
$ . venv/bin/activate
$ pip install -e .
$ pip install build pytest twine
$ python3 -m build
-> Successfully built vipscore_common-0.1.6.tar.gz and vipscore_common-0.1.6-py3-none-any.whl
$ pytest
-> [100%] ======================= 2 passed in 0.27s ==========================
$ python3 -m twine upload --repository gitlab dist/* --verbose
-> Uploading vipscore_common-0.1.6-py3-none-any.whl
-> 201 Created
-> Uploading vipscore_common-0.1.6.tar.gz
-> 201 Created
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment