From b7ffa255981ba3f5f22f7445a6d6415863575cdf Mon Sep 17 00:00:00 2001 From: ds-sebastianchwilczynski <166019576+ds-sebastianchwilczynski@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:14:27 +0200 Subject: [PATCH] feat: automatic versioning (#16) --- .bumpversion.cfg | 17 ------ .github/workflows/check_future_version.yml | 22 ++++++++ .github/workflows/release.yml | 52 ++++++++++++++++++ bump_version.sh | 3 -- pyproject.toml | 61 +++++++++++++++++++++- setup.cfg | 4 +- src/dbally/VERSION | 1 - src/dbally/__version__.py | 5 +- 8 files changed, 137 insertions(+), 28 deletions(-) delete mode 100644 .bumpversion.cfg create mode 100644 .github/workflows/check_future_version.yml create mode 100644 .github/workflows/release.yml delete mode 100755 bump_version.sh delete mode 100644 src/dbally/VERSION diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index fdd0cc9a..00000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,17 +0,0 @@ -[bumpversion] -current_version = 0.0.2 -commit = False -tag = False -parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+))? -serialize = - {major}.{minor}.{patch}-{release} - {major}.{minor}.{patch} - -[bumpversion:part:release] -optional_value = prod -first_value = dev -values = - dev - prod - -[bumpversion:file:./src/dbally/VERSION] diff --git a/.github/workflows/check_future_version.yml b/.github/workflows/check_future_version.yml new file mode 100644 index 00000000..d0e6f10c --- /dev/null +++ b/.github/workflows/check_future_version.yml @@ -0,0 +1,22 @@ +name: Check New Version + +on: workflow_dispatch + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + root_options: "-v --noop" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d5fc169d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Semantic Release + +on: + workflow_dispatch: + inputs: + releaseType: + description: "version update type" + required: true + type: choice + default: "automatic" + options: + - "automatic" + - "major" + - "minor" + - "patch" + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + + environment: + name: pypi + url: https://pypi.org/p/dbally + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Python Semantic Release Manual + id: release_manual + if: ${{ github.event.inputs.releaseType != 'automatic' }} + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + force: ${{ github.event.inputs.releaseType }} + + - name: Python Semantic Release Automatic + id: release_automatic + if: ${{ github.event.inputs.releaseType == 'automatic' }} + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + if: steps.release_manual.outputs.released == 'true' || steps.release_automatic.outputs.released == 'true' diff --git a/bump_version.sh b/bump_version.sh deleted file mode 100755 index d527d5fd..00000000 --- a/bump_version.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -e -bump2version --verbose --commit $@ \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index a647c32b..0b1920e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -145,4 +145,63 @@ min-similarity-lines=10 exclude_dirs = ["venv",] # B101 disables errors for asserts in the code # remember to not use asserts for security and control flows -skips = ["B101"] \ No newline at end of file +skips = ["B101"] + + +[tool.semantic_release] +assets = [] +commit_message = "{version}\n\nAutomatically generated by python-semantic-release" +commit_parser = "angular" +logging_use_named_masks = false +major_on_zero = false +allow_zero_version = true +tag_format = "v{version}" +version_variables = [ + "setup.cfg:version", + "src/dbally/__version__.py:__version__", +] +build_command = "pip install build && python -m build" + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease_token = "rc" +prerelease = false + +[tool.semantic_release.changelog] +template_dir = "templates" +changelog_file = "CHANGELOG.md" +exclude_commit_patterns = [] + +[tool.semantic_release.changelog.environment] +block_start_string = "{%" +block_end_string = "%}" +variable_start_string = "{{" +variable_end_string = "}}" +comment_start_string = "{#" +comment_end_string = "#}" +trim_blocks = false +lstrip_blocks = false +newline_sequence = "\n" +keep_trailing_newline = false +extensions = [] +autoescape = true + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] +default_bump_level = 0 + +[tool.semantic_release.remote] +name = "origin" +type = "github" +ignore_token_for_push = false +insecure = false + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true diff --git a/setup.cfg b/setup.cfg index 31cf051f..471f708e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = dbally -# do not change version by hand: use bump_version.sh -version = file: src/dbally/VERSION +# do not change version by hand, is will be automatically updated during the release action +version = 0.0.2 description = "Efficient, consistent and secure library for querying structured data with natural language" author = deepsense.ai author_email = contact@deepsense.ai diff --git a/src/dbally/VERSION b/src/dbally/VERSION deleted file mode 100644 index 7bcd0e36..00000000 --- a/src/dbally/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.2 \ No newline at end of file diff --git a/src/dbally/__version__.py b/src/dbally/__version__.py index 4d271e86..91857912 100644 --- a/src/dbally/__version__.py +++ b/src/dbally/__version__.py @@ -1,5 +1,2 @@ """Version information.""" -from pathlib import Path - -version_file = Path(__file__).absolute().parents[0] / "VERSION" -__version__ = version_file.read_text(encoding="utf-8").strip() +__version__ = "0.0.2"