From 8229635515b7419fe5af3a3e7fd8d48ba3b17c8f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 20:20:38 +0000 Subject: [PATCH 1/2] Fix bump-version to use YAML parsing for packages.yml updates The sed-based version replacement in bump-version.yml had two issues: 1. It only matched 'version: X.Y.Z' patterns, missing the case where master has a git hash reference for dbt-data-reliability 2. It also matched commented-out version lines Replace the sed commands for packages.yml with a Python script that properly parses the YAML and handles both cases: - Updates an existing package version reference - Replaces a git hash reference with a proper package version The sed replacement for docs snippets and pyproject.toml is kept as-is since those files always have a version pattern. Co-Authored-By: Itamar Hartstein --- .github/scripts/bump_packages_version.py | 67 ++++++++++++++++++++++++ .github/workflows/bump-version.yml | 27 +++++++--- 2 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 .github/scripts/bump_packages_version.py diff --git a/.github/scripts/bump_packages_version.py b/.github/scripts/bump_packages_version.py new file mode 100644 index 000000000..86d2ad216 --- /dev/null +++ b/.github/scripts/bump_packages_version.py @@ -0,0 +1,67 @@ +import os +import sys + +import yaml + +PACKAGES_FILE = "./elementary/monitor/dbt_project/packages.yml" +HELPER_COMMENTS = """ + # NOTE - for unreleased CLI versions we often need to update the package version to a commit hash (please leave this + # commented, so it will be easy to access) + # - git: https://github.com/elementary-data/dbt-data-reliability.git + # revision: + # When releasing a new version of the package, if the current version is using a commit hash, update the version to the new version. + # - package: elementary-data/elementary + # version: {version} +""" + + +def bump_packages_version(version: str) -> None: + with open(PACKAGES_FILE) as f: + data = yaml.safe_load(f) + + packages = data.get("packages") or [] + + new_packages = [] + elementary_found = False + for pkg in packages: + if "git" in pkg and "dbt-data-reliability" in pkg["git"]: + # Replace git hash reference with proper package reference + new_packages.append( + { + "package": "elementary-data/elementary", + "version": version, + } + ) + elementary_found = True + elif pkg.get("package") == "elementary-data/elementary": + # Update existing package version + pkg["version"] = version + new_packages.append(pkg) + elementary_found = True + else: + new_packages.append(pkg) + + if not elementary_found: + print( + "::error::Could not find elementary-data/elementary or " + "dbt-data-reliability entry in packages.yml" + ) + sys.exit(1) + + data["packages"] = new_packages + with open(PACKAGES_FILE, "w") as f: + yaml.dump(data, f, default_flow_style=False, sort_keys=False) + + # Append the helper comments for developer convenience + with open(PACKAGES_FILE, "a") as f: + f.write(HELPER_COMMENTS.format(version=version)) + + print(f"Updated packages.yml to version {version}") + + +if __name__ == "__main__": + version = os.environ.get("PKG_VERSION", "") + if not version: + print("::error::PKG_VERSION environment variable is not set") + sys.exit(1) + bump_packages_version(version) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 69b25e9ab..bfd1a47e0 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -61,16 +61,27 @@ jobs: - name: Bump version run: | sed -i 's/^version = "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"/version = "${{ inputs.cli-version }}"/' ./pyproject.toml - - name: Bump version for package (using input) - if: ${{ needs.validate-version.outputs.validated-dbt-package-version != ''}} + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install PyYAML + run: pip install pyyaml + - name: Determine package version + id: pkg-version run: | - sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ needs.validate-version.outputs.validated-dbt-package-version }}/' ./elementary/monitor/dbt_project/packages.yml - sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ needs.validate-version.outputs.validated-dbt-package-version }}/' ./docs/_snippets/quickstart-package-install.mdx - - name: Bump version for package (using default) - if: ${{ needs.validate-version.outputs.validated-dbt-package-version == ''}} + if [ -n "${{ needs.validate-version.outputs.validated-dbt-package-version }}" ]; then + echo "version=${{ needs.validate-version.outputs.validated-dbt-package-version }}" >> $GITHUB_OUTPUT + else + echo "version=${{ needs.validate-version.outputs.default-dbt-package-version }}" >> $GITHUB_OUTPUT + fi + - name: Bump version for packages.yml + env: + PKG_VERSION: ${{ steps.pkg-version.outputs.version }} + run: python .github/scripts/bump_packages_version.py + - name: Bump version for docs snippet run: | - sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ needs.validate-version.outputs.default-dbt-package-version }}/' ./elementary/monitor/dbt_project/packages.yml - sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ needs.validate-version.outputs.default-dbt-package-version }}/' ./docs/_snippets/quickstart-package-install.mdx + sed -i 's/version: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/version: ${{ steps.pkg-version.outputs.version }}/' ./docs/_snippets/quickstart-package-install.mdx - name: Commit changes run: git commit -am "release v${{ inputs.cli-version }}" - name: Push code From e69aaabaf24e1b602dc628f23b3044f703a13e3a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 00:43:48 +0000 Subject: [PATCH 2/2] Add guard for invalid dbt-package-version input Co-Authored-By: Itamar Hartstein --- .github/workflows/bump-version.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index bfd1a47e0..efa9d7c67 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -70,7 +70,10 @@ jobs: - name: Determine package version id: pkg-version run: | - if [ -n "${{ needs.validate-version.outputs.validated-dbt-package-version }}" ]; then + if [ -n "${{ inputs.dbt-package-version }}" ] && [ -z "${{ needs.validate-version.outputs.validated-dbt-package-version }}" ]; then + echo "::error::Invalid dbt-package-version input" + exit 1 + elif [ -n "${{ needs.validate-version.outputs.validated-dbt-package-version }}" ]; then echo "version=${{ needs.validate-version.outputs.validated-dbt-package-version }}" >> $GITHUB_OUTPUT else echo "version=${{ needs.validate-version.outputs.default-dbt-package-version }}" >> $GITHUB_OUTPUT