From 383b3dee7dd3e1e5c9aff3f56787acc47735dd24 Mon Sep 17 00:00:00 2001 From: epplepascal <37149717+epplepascal@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:27:53 +0200 Subject: [PATCH] Feature/continuous delivery (#12) * added setuptools section in .toml file * deleted setup.cfg file as it no more needed * fixed visiumlint command and added dependencies on pyproject.toml file * added MAJOR_UPDATE env variable * made workflow dispatch available on this branch * added cd.yaml * modified name of branch from 'master' to 'main' in ci.yml --------- Co-authored-by: Pascal Epple --- .github/workflows/cd.yaml | 67 +++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 4 +-- pyproject.toml | 15 +++++++-- setup.cfg | 16 ---------- 4 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/cd.yaml delete mode 100644 setup.cfg diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..90eb50e --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,67 @@ + +name: CD Pipeline + +on: + push: + branches: [ main ] + workflow_dispatch: + inputs: + major_update: + description: 'Set it to true to bump a major version' + required: false + default: false + type: choice + options: + - true + - false + +jobs: + publish-to-pypi: + runs-on: ubuntu-latest + steps: + - name: Clone the repository with full history depth to retrieve all tags + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - run: | + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools wheel + python -m pip install --upgrade twine + python -m pip install --upgrade setuptools_scm + python -m pip install --upgrade build + python -m pip install --upgrade semver + + - name: Increment the git tag + run: | + # get the current git tag + CURRENT_TAG=$(git describe --tags --abbrev=0) + if [ "${{inputs.major_update}}" == "true" ]; then + # Increment the tag by a major version with the semver python package + NEW_TAG=$(python -c "import semver; print(semver.bump_major('$CURRENT_TAG'))") + else + # Increment the tag by a minor version with the semver python package + NEW_TAG=$(python -c "import semver; print(semver.bump_minor('$CURRENT_TAG'))") + fi + git tag $NEW_TAG + # push the tag to the remote repository + git push origin $NEW_TAG + + - name: Retrieve the package version using setuptools_scm and publish to PyPI + run: | + # Use setuptools_scm to get the current version and echo it + PACKAGE_VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version())") + echo "Package version: $PACKAGE_VERSION" + + # Build the package using setuptools_scm for versioning + python -m build + + # Publish the package to PyPI using twine + python -m twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7b8a3c..a259dea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] workflow_dispatch: jobs: diff --git a/pyproject.toml b/pyproject.toml index eda9d13..1d4218a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,18 @@ - +[project] +name = "visiumlint" +dynamic = ["version"] +description = "All of your favorite linters and formatters gathered in a single command." +dependencies = ["black", "isort", "mypy", "pydocstyle", "pylint", "typer"] [build-system] -requires = ["setuptools"] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" +[project.scripts] +visiumlint = "visiumlint.main:main" + +[tool.setuptools_scm] + [tool.black] line-length = 120 @@ -29,4 +38,4 @@ max-line-length = "200" [tool.pydocstyle] add-ignore = "D107, D104, D103" -convention = "google" +convention = "google" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a85539a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[metadata] -name = visiumlint -version = 0.0.1 - -[options] -include_package_data = True -install_requires = - black - isort - mypy - pydocstyle - pylint - typer -[options.entry_points] -console_scripts = - visiumlint = visiumlint.main:main \ No newline at end of file