diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..3ce520e --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,40 @@ +name: Publish to Pypi +on: + push: + branches: + - 'master' + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index e60dee2..c727ae9 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,6 @@ cython_debug/ # Node stuff package-lock.json node_modules/ + +# package +dist/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d69b1d2..8192201 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: black - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1ccc9a1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) [2023] [STRV-DS-Department] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 70c3701..63eb8bc 100644 --- a/README.md +++ b/README.md @@ -20,26 +20,8 @@ work with OpenSearch. ## :computer: Installation -### Local environment - -1. Have a valid ssh authentication key on your local machine. -2. Add `git+ssh://git@github.com/strvcom/strv-ds-opensearch-manager.git` to `requirements.txt`. -3. Create a venv or conda environment using `requirements.txt`. - -### Docker-compose -1. Do all the 'local environment' steps above. -2. Run docker compose with reference to the local key as an argument (e.g. `docker-compose build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_ed25519)"`) -3. Add the following to the Dockerfile: -``` -# Add ssh private key into container -ARG SSH_PRIVATE_KEY -RUN mkdir ~/.ssh/ -RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_ed25519 -RUN chmod 600 ~/.ssh/id_ed25519 -RUN ssh-keyscan github.com >> ~/.ssh/known_hosts -``` - - **_NOTE:_** When using Makefile use `SSH_PRIVATE_KEY="$$(cat ~/.ssh/id_ed25519)`. +1. Create a new virtual environment. +2. Run `pip install osmanager`. ## :hammer: Usage @@ -249,8 +231,32 @@ For running linters from GitHub actions locally, you need to do the following. 1. From root project directory, run: `pre-commit run --all-files` ### :heavy_plus_sign: Versioning +For information on semantic versioning, see [semver.org](https://semver.org/). + +Given a version number MAJOR.MINOR.PATCH, increment the: + +- MAJOR version when you make incompatible API changes +- MINOR version when you add functionality in a backwards compatible manner +- PATCH version when you make backwards compatible bug fixes + +When incrementing the MAJOR version, reset the MINOR and PATCH versions to 0. +When incrementing the MINOR version, reset the PATCH version to 0. -*TODO* +When a version is released, a tag should be created in the format `vMAJOR.MINOR.PATCH`. + +Follow the steps below to create a new release: +1. Update `package.json` with the new version number. +2. Add the tag to the current branch like this: + +``` +git tag -a v1.0.0 -m "Release version 1.0.0" +``` +3. Push the tag to the remote repository: + +``` +git push origin --tags +``` +4. Create a new pull request with the new version number and merge it to the `master` branch. ### :pencil: Contributors diff --git a/osman/__init__.py b/osman/__init__.py index 118148d..f08240d 100644 --- a/osman/__init__.py +++ b/osman/__init__.py @@ -1,4 +1,5 @@ """Osman package init.""" + # flake8: noqa from osman.config import OsmanConfig from osman.osman import Osman diff --git a/package.json b/package.json index a084229..9a5e613 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { - "name": "strv-ds-opensearch-manager", - "version": "1.0.0", - "description": "STRV OpenSearch manager repository.", + "name": "osmanager", + "version": "1.0.2", + "description": "OpenSearch manager repository.", "author": "STRV DS Department ", + "email": "datascience.dept@strv.com", + "url": "https://github.com/strvcom/osman", "contributors": [ + "Niek Mereu ", + "Vladimir Kadlec ", "Jaroslav Bezdek " ], "license": "ISC", diff --git a/setup.py b/setup.py index 3a44343..8910322 100755 --- a/setup.py +++ b/setup.py @@ -1,18 +1,24 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """Package setup.""" +import json from setuptools import find_packages, setup with open("README.md", mode="r", encoding="utf-8") as readme_file: long_description = readme_file.read() +with open("package.json", mode="r", encoding="utf-8") as package_file: + package_info = package_file.read() +package_info = json.loads(package_info) + setup( - name="osman", - version="0.0.1", - author="STRV DS Department", - author_email="datascience.dept@strv.com", - description="STRV OpenSearch manager.", + name=package_info["name"], + version=package_info["version"], + author=package_info["author"], + author_email=package_info["email"], + url=package_info["url"], + description=package_info["description"], long_description_content_type="text/markdown", long_description=long_description, packages=find_packages( @@ -37,11 +43,11 @@ "py>=1.11", "pyparsing>=3.0", "requests>=2.28", - "tomli>=2.0.", + "tomli>=2.0", "urllib3>=1.26", "requests-aws4auth>=1.1", "deepdiff>=6.2", ], - python_requires=">=3.8", + python_requires=">=3.9", include_package_data=True, )