You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2026/03/16 22:12:41 UTC

(airflow-site) branch auto-theme-version-bump created (now efd4467a03)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a change to branch auto-theme-version-bump
in repository https://gitbox.apache.org/repos/asf/airflow-site.git


      at efd4467a03 Add automatic version bumping for sphinx_airflow_theme

This branch includes the following new commits:

     new efd4467a03 Add automatic version bumping for sphinx_airflow_theme

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(airflow-site) 01/01: Add automatic version bumping for sphinx_airflow_theme

Posted by po...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch auto-theme-version-bump
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit efd4467a0308c7f554410a0b7cc90be69c829db8
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Mon Mar 16 23:12:15 2026 +0100

    Add automatic version bumping for sphinx_airflow_theme
    
    Add a pre-commit hook that detects changes to theme files and
    automatically bumps the patch version. The CI workflow is updated
    to skip theme build/upload/publish when the version is unchanged,
    avoiding unnecessary work on non-theme commits.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <no...@anthropic.com>
---
 .github/workflows/build.yml                        | 23 +++++-
 .pre-commit-config.yaml                            |  6 ++
 sphinx_airflow_theme/.theme_files_hash             |  1 +
 sphinx_airflow_theme/LATEST_VERSION.txt            |  1 +
 sphinx_airflow_theme/check_and_bump_version.sh     | 96 ++++++++++++++++++++++
 .../sphinx_airflow_theme/__init__.py               |  2 +-
 6 files changed, 127 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e85b818620..34472a8cf8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -160,14 +160,32 @@ jobs:
       - name: πŸ”§ Copy files from site to theme
         run: |
           ./site.sh prepare-theme
+      - name: πŸ” Check if sphinx_airflow_theme changed
+        id: check-theme
+        run: |
+          NEW_VERSION=$(cat sphinx_airflow_theme/LATEST_VERSION.txt | tr -d '[:space:]')
+          PUBLISHED_VERSION=""
+          if [ -f dist/sphinx-airflow-theme/LATEST_VERSION.txt ]; then
+            PUBLISHED_VERSION=$(cat dist/sphinx-airflow-theme/LATEST_VERSION.txt | tr -d '[:space:]')
+          fi
+          if [ "${NEW_VERSION}" != "${PUBLISHED_VERSION}" ]; then
+            echo "theme_changed=true" >> "${GITHUB_OUTPUT}"
+            echo "sphinx_airflow_theme version changed: ${PUBLISHED_VERSION} -> ${NEW_VERSION}"
+          else
+            echo "theme_changed=false" >> "${GITHUB_OUTPUT}"
+            echo "sphinx_airflow_theme version unchanged (${NEW_VERSION}), skipping theme upload"
+          fi
       - name: πŸ”§ Prepare sphinx_airflow_theme package ️
+        if: steps.check-theme.outputs.theme_changed == 'true'
         working-directory: sphinx_airflow_theme
         run: |
           uv build
       - name: πŸ“¦ Copy sphinx_airflow_theme package to dist
+        if: steps.check-theme.outputs.theme_changed == 'true'
         run: |
           mkdir -p dist/sphinx-airflow-theme
           cp sphinx_airflow_theme/dist/* dist/sphinx-airflow-theme/
+          cp sphinx_airflow_theme/LATEST_VERSION.txt dist/sphinx-airflow-theme/
       - name: πŸ”„Refresh PMC/COMMITTERS profiles
         env:
           PMC_COMMITTERS_FILES: landing-pages/site/data/committers.json,landing-pages/site/data/pmc.json
@@ -194,6 +212,7 @@ jobs:
           echo "Running git push to ${PUBLISH_BRANCH} branch"
           git push origin ${PUBLISH_BRANCH}
       - name: πŸš€ Upload sphinx_airflow_theme package as artifact
+        if: steps.check-theme.outputs.theme_changed == 'true'
         uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f  # v7.0.0
         with:
           name: airflow-sphinx-theme
@@ -201,12 +220,14 @@ jobs:
           if-no-files-found: error
           retention-days: 14
       - name: πŸ”§ Build theme demo
+        if: steps.check-theme.outputs.theme_changed == 'true'
         working-directory: sphinx_airflow_theme
         run: |
           pip install ./dist/sphinx_airflow_theme-*.whl
           cd demo
           ./docs.sh build
       - name: πŸš€ Upload sphinx_airflow_theme demo as artifact
+        if: steps.check-theme.outputs.theme_changed == 'true'
         uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f  # v7.0.0
         with:
           name: airflow-sphinx-theme-demo
@@ -219,7 +240,7 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GITHUB_COMMIT: ${{ github.sha }}
           GITHUB_REF: ${{ github.ref }}
-        if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false'
+        if: steps.check-theme.outputs.theme_changed == 'true' && (env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false')
         run: |
           set -x
           if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index cc90f867a6..a4377746f0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -136,6 +136,12 @@ repos:
           - --fuzzy-match-generates-todo
   - repo: local
     hooks:
+      - id: check-sphinx-theme-version
+        name: Check and bump sphinx_airflow_theme version if files changed
+        language: script
+        entry: sphinx_airflow_theme/check_and_bump_version.sh
+        files: ^sphinx_airflow_theme/
+        pass_filenames: false
       - id: shellcheck
         name: Check Shell scripts syntax correctness
         language: docker_image
diff --git a/sphinx_airflow_theme/.theme_files_hash b/sphinx_airflow_theme/.theme_files_hash
new file mode 100644
index 0000000000..c3dfc8db26
--- /dev/null
+++ b/sphinx_airflow_theme/.theme_files_hash
@@ -0,0 +1 @@
+07df2243846a413e643fa9ea4ba7faa06cb8431317caa58243b93a011017c0f2
diff --git a/sphinx_airflow_theme/LATEST_VERSION.txt b/sphinx_airflow_theme/LATEST_VERSION.txt
new file mode 100644
index 0000000000..d15723fbe8
--- /dev/null
+++ b/sphinx_airflow_theme/LATEST_VERSION.txt
@@ -0,0 +1 @@
+0.3.2
diff --git a/sphinx_airflow_theme/check_and_bump_version.sh b/sphinx_airflow_theme/check_and_bump_version.sh
new file mode 100755
index 0000000000..fe2c65ecce
--- /dev/null
+++ b/sphinx_airflow_theme/check_and_bump_version.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Pre-commit hook that checks if sphinx_airflow_theme files have changed.
+# If they have, it bumps the patch version and updates the stored hash.
+
+set -euo pipefail
+
+REPO_ROOT="$(git rev-parse --show-toplevel)"
+THEME_DIR="${REPO_ROOT}/sphinx_airflow_theme"
+THEME_MODULE="${THEME_DIR}/sphinx_airflow_theme"
+HASH_FILE="${THEME_DIR}/.theme_files_hash"
+VERSION_FILE="${THEME_DIR}/LATEST_VERSION.txt"
+INIT_FILE="${THEME_MODULE}/__init__.py"
+
+compute_theme_hash() {
+    # Hash all theme files (excluding version lines in __init__.py) plus pyproject.toml.
+    # We use shasum via stdin (< "$f") to avoid embedding absolute paths in the hash.
+    # File paths are echoed separately so the hash is stable regardless of working directory.
+    (
+        find "${THEME_MODULE}" -type f | sort | while read -r f; do
+            local relative
+            relative="${f#"${REPO_ROOT}/"}"
+            if [ "$f" = "${INIT_FILE}" ]; then
+                echo "${relative}"
+                grep -v '^__version__' "$f" | grep -v '^__version_full__' | shasum -a 256 | cut -d' ' -f1
+            else
+                echo "${relative}"
+                shasum -a 256 < "$f" | cut -d' ' -f1
+            fi
+        done
+        echo "sphinx_airflow_theme/pyproject.toml"
+        shasum -a 256 < "${THEME_DIR}/pyproject.toml" | cut -d' ' -f1
+    ) | shasum -a 256 | cut -d' ' -f1
+}
+
+current_hash=$(compute_theme_hash)
+
+if [ -f "${HASH_FILE}" ]; then
+    stored_hash=$(head -1 "${HASH_FILE}" | tr -d '[:space:]')
+else
+    stored_hash=""
+fi
+
+if [ "${current_hash}" = "${stored_hash}" ]; then
+    # No changes, verify version file is in sync
+    current_version=$(grep '^__version__' "${INIT_FILE}" | head -1 | sed "s/.*= *['\"]//;s/['\"]//")
+    stored_version=$(head -1 "${VERSION_FILE}" | tr -d '[:space:]')
+    if [ "${current_version}" != "${stored_version}" ]; then
+        echo "${current_version}" > "${VERSION_FILE}"
+        git add "${VERSION_FILE}"
+        echo "sphinx_airflow_theme: synced LATEST_VERSION.txt to ${current_version}"
+    fi
+    exit 0
+fi
+
+# Hash changed - bump the patch version
+current_version=$(grep '^__version__' "${INIT_FILE}" | head -1 | sed "s/.*= *['\"]//;s/['\"]//")
+IFS='.' read -r major minor patch <<< "${current_version}"
+new_patch=$((patch + 1))
+new_version="${major}.${minor}.${new_patch}"
+
+echo "sphinx_airflow_theme: files changed, bumping version ${current_version} -> ${new_version}"
+
+# Update __init__.py
+sed -i.bak "s/^__version__ = .*/__version__ = '${new_version}'/" "${INIT_FILE}"
+sed -i.bak "s/^__version_full__ = .*/__version_full__ = __version__/" "${INIT_FILE}"
+rm -f "${INIT_FILE}.bak"
+
+# Recompute hash after version bump (since __init__.py changed but version lines are excluded)
+new_hash=$(compute_theme_hash)
+
+# Update stored hash and version
+echo "${new_hash}" > "${HASH_FILE}"
+echo "${new_version}" > "${VERSION_FILE}"
+
+# Stage the modified files
+git add "${INIT_FILE}" "${HASH_FILE}" "${VERSION_FILE}"
+
+echo "sphinx_airflow_theme: updated hash and version files"
+exit 1
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
index d71e298020..74c21d4d4a 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
@@ -18,7 +18,7 @@
 from os import path
 from sphinx.application import Sphinx
 
-__version__ = '0.3.1'
+__version__ = '0.3.2'
 __version_full__ = __version__