From 60c33fbf6987bc9a4f64b670415fbce37e1aa229 Mon Sep 17 00:00:00 2001 From: Denis Kokorin Date: Sun, 7 Jul 2024 10:30:26 +0300 Subject: [PATCH] Dynamic version, release preparation (#25) --- .github/workflows/release.yml | 29 +++++++++++++++++++ .../{test-publish.yml => test-release.yml} | 4 ++- .github/workflows/test.yml | 1 + .gitignore | 3 ++ dbt_pumpkin/cli.py | 1 + pyproject.toml | 17 +++++++++-- 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml rename .github/workflows/{test-publish.yml => test-release.yml} (89%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ec159ab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Release + +on: + push: + branches: + - release/** + tags: + - v* +env: + PIP_CACHE_DIR: .cache/pip + PRE_COMMIT_HOME: .cache/pre-commit + HATCH_CACHE_DIR: .cache/hatch + + HATCH_INDEX_USER: __token__ + HATCH_INDEX_REPO: main + HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }} +jobs: + test-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: pip + - run: pip install hatch + - run: hatch version + - run: hatch build + - run: hatch publish diff --git a/.github/workflows/test-publish.yml b/.github/workflows/test-release.yml similarity index 89% rename from .github/workflows/test-publish.yml rename to .github/workflows/test-release.yml index aa5e216..7b2a463 100644 --- a/.github/workflows/test-publish.yml +++ b/.github/workflows/test-release.yml @@ -1,9 +1,10 @@ -name: Test Publish +name: Test Release on: push: branches: - main + - release/** env: PIP_CACHE_DIR: .cache/pip PRE_COMMIT_HOME: .cache/pre-commit @@ -22,5 +23,6 @@ jobs: python-version: 3.12 cache: pip - run: pip install hatch + - run: hatch version - run: hatch build - run: hatch publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8914746..aaa0a19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - release/** pull_request: types: - opened diff --git a/.gitignore b/.gitignore index c65521a..df7be7b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ __pycache__ /.vscode /.idea /dist + +#auto-generated +/dbt_pumpkin/version.py diff --git a/dbt_pumpkin/cli.py b/dbt_pumpkin/cli.py index 4cf318e..84162a3 100644 --- a/dbt_pumpkin/cli.py +++ b/dbt_pumpkin/cli.py @@ -25,6 +25,7 @@ def set_up_logging(debug): @click.group +@click.version_option() def cli(): pass diff --git a/pyproject.toml b/pyproject.toml index 206926d..45adf1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "dbt-pumpkin" -version = "0.1.0" description = "" authors = [ {name = "Denis Kokorin", email = "kokorin86@gmail.com"} @@ -12,6 +11,7 @@ dependencies = [ "ruamel-yaml>=0.17", "click>=8.1.0" ] +dynamic = ["version"] [project.urls] "Source code" = "https://github.com/kokorin/dbt-pumpkin" @@ -21,6 +21,9 @@ dbt-pumpkin = "dbt_pumpkin.cli:main" [tool.hatch] +[tool.hatch.version] +source = "versioningit" + [tool.hatch.build] exclude = [ "/.github", @@ -28,6 +31,10 @@ exclude = [ "/.pre-commit-config.yaml", "/.gitignore" ] +artifacts = ["dbt_pumpkin/version.py"] + +[tool.hatch.build.hooks.version] +path = "dbt_pumpkin/version.py" [tool.hatch.envs.default] dependencies = [ @@ -63,6 +70,12 @@ dbt = ["1.5", "1.6", "1.7", "1.8"] python = ["3.12"] dbt = ["1.7", "1.8"] +[tool.versioningit] + +[tool.versioningit.vcs] +method = "git" +default-tag = "v0.0.0" + [tool.ruff] # cache directory for GH actions extend-exclude = [".cache"] @@ -81,5 +94,5 @@ filterwarnings = [ ] [build-system] -requires = ["hatchling"] +requires = ["hatchling", "versioningit"] build-backend = "hatchling.build"