From f0f1893508518ccd1675f6d2fbfb47022b242a44 Mon Sep 17 00:00:00 2001 From: Coby Simmons Date: Tue, 26 Sep 2023 21:23:43 +0200 Subject: [PATCH] Add publish workflow --- .github/workflows/publish.yml | 30 ++++++++++++++++++++++++++++++ sqlxfluff/formatters/indent.py | 2 +- sqlxfluff/formatters/sqlx.py | 5 ----- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6a75023 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: Publish Python package + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + + - name: Build and publish + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + run: | + poetry build + poetry publish diff --git a/sqlxfluff/formatters/indent.py b/sqlxfluff/formatters/indent.py index 2a6f04c..b2a1411 100644 --- a/sqlxfluff/formatters/indent.py +++ b/sqlxfluff/formatters/indent.py @@ -23,7 +23,7 @@ def replace_with_indentation(source, target, replacement): # Determine the start of the line where the target string was found line_start = source.rfind("\n", 0, match.start()) + 1 - # Compute the indentation as the spaces from the start of the line until the first non-space character + # Compute number of spaces at start of the line indentation_level = 0 for char in source[line_start : match.start()]: if char != " ": diff --git a/sqlxfluff/formatters/sqlx.py b/sqlxfluff/formatters/sqlx.py index 8c657ac..2526ffc 100644 --- a/sqlxfluff/formatters/sqlx.py +++ b/sqlxfluff/formatters/sqlx.py @@ -1,10 +1,5 @@ -from sys import exit # pylint: disable=redefined-builtin - import sqlfluff -from termcolor import cprint -from ..constants import EXIT_FAIL -from ..parsing import parse_sqlx from .base import format_config, format_template from .indent import replace_with_indentation