Commit 93a06e03 authored by Gregory Harris's avatar Gregory Harris
Browse files

Add package publish to pipeline

Changing stage from publish to deploy, because publish is not permitted

For publish change to root folder.

More publish tweeks

More tweeks to CI/CD

More CI/CD tweeks

Adding build number to version.

More CI/CD tweeks

CI version adjustment

Refining the version numbering and adding a new build stage to dry run packaging.

Fixing the test packaging build task

Update the readme with install and deploy instructions.
parent 6b45d6b4
default:
image: python:3
variables:
BUILD_ID: $CI_PIPELINE_IID
BUILD_TAG: $CI_COMMIT_TAG
before_script:
- python --version
- cd src
......@@ -16,4 +20,19 @@ run-flake8:
run-test:
stage: test
script:
- pipenv run pytest
\ No newline at end of file
- pipenv run pytest
run-test-package:
stage: test
script:
- cd ../
- python setup.py sdist bdist_wheel
publish:
stage: deploy
script:
- cd ../
- pip install twine
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
when: manual
......@@ -8,6 +8,32 @@
2. This is a wrapper behind the Wellbore DDMS [API](https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/-/blob/master/spec/generated/openapi.json)
## Install from Package Registry
The simplest way to install `lasloader` is from the community package registry. If you have `pip` installed simply run:
```
pip install lasloader --extra-index-url https://community.opengroup.org/api/v4/projects/801/packages/pypi/simple
```
This will download and install `lasloader` on your machine.
## Usage
The `lasloader` package has a command line interface called `lascli` which has the general syntax:
```
lascli <group> <command> options
```
Help for any group or command can be obtained by using the `-h` option.
There are several groups:
* `download`: Download a welllog and curve data to a las format file.
* `fileload`: Dry run of the ingest command, instead of uploading data to the OSDU instance it creates json files for the wellbore and welllog.
* `ingest`: Upload a wellbore, welllog and/or bulk data to an OSDU instance
* `list`: List the data held in OSDU for a given wellbore or welllog id.
* `search`: Search for a wellbore given a well name.
* `update`: Update the existing bulk data for a given welllog
## Development
The application uses a virtual environment managed by pipenv. To execute the application and run the tests you will need to install Python 3.9 and pipenv.
......@@ -99,29 +125,15 @@ This installs the package in a virtual environment. The CLI can then be run usin
pipenv run lascli
```
Before build and deploy ensure that the setup.py and the pipfile.lock dependencies synced, by running:
```
pipenv-setup sync
```
Check that the version number in the `src/lasloader/__init__.py` file is correct.
### Creating distribution archives
To create a distribution run:
```
python setup.py sdist bdist_wheel
```
This will create both source and binary wheel distributions. The package can then be deployed using:
```
pip install .
```
### Publish to the Package Registry
### Publish the package distribution
Packages are published to the community package registry via the CI pipeline. Package publish is a manually triggered job. To run it navigate to the CI/CD jobs page of the `lasloader` module:
[https://community.opengroup.org/osdu/platform/data-flow/data-loading/wellbore-ddms-las-loader/-/jobs](https://community.opengroup.org/osdu/platform/data-flow/data-loading/wellbore-ddms-las-loader/-/jobs).
To be determined...
Run the publish job for the build you want to publish. It will build and upload `lasloader` with a specific package version number. The package version number is the `__VERSION__` found in the `__init__.py` file for the module followed by a build tag. The build tag is based upon the CI build_id:
1. The default build tag is an alpha release of the form 1.2.3a456
1. If the repo branch has been tagged with a string starting wih `BETA` then the beta release form is used 1.2.3b456.
1. If the repo branch has been tagged with a string starting wih `RELEASE` then the primary release form is used 1.2.3.456.
## Config file
......
......@@ -20,9 +20,32 @@ __VERSION__ = re.search(
).group(1)
def prepare_version():
# Construct the version number
build_tag = os.getenv("BUILD_TAG")
build_id = os.getenv("BUILD_ID")
if build_id is None:
# local dev build (non-CI)
version = f"{__VERSION__}.dev"
elif build_tag is not None and build_tag.lower().startswith('release'):
# Tagged as release
version = f"{__VERSION__}.{build_id}"
elif build_tag is not None and build_tag.lower().startswith('beta'):
# Tagged as beta release
version = f"{__VERSION__}.beta{build_id}"
else:
# Standard CI release.
version = f"{__VERSION__}.alpha{build_id}"
print(f"Packaging release: {version}")
return version
setup(
name="lasloader",
version=__VERSION__,
version=prepare_version(),
author="BP",
author_email="greg.harris1@bp.com",
description="OSDU LAS file ingest - command line interface",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment