From 3c69ca6f7574199dd615bede347b08d78246739e Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Sun, 16 Nov 2025 00:26:34 +0000 Subject: [PATCH] feat(release): remove version tag prefix from release titles HACS automatically displays the version number before release titles, causing duplication when version tags are included in the title. Changes: - scripts/generate-release-notes: All backends now generate intelligent titles without version prefix (git-cliff, manual, and copilot) - scripts/generate-release-notes: Added smart title generation based on commit analysis (feat/fix counts) for git-cliff and manual backends - scripts/generate-release-notes: Unified section headers to use ### (H3) instead of ## (H2) for consistency across all backends - scripts/generate-release-notes: Auto-update feature now uses extracted title without prepending version tag - .github/workflows/release.yml: Extract title directly from generated release notes (first line with "# ") instead of manual construction - .github/workflows/release.yml: Removed redundant "Generate release title" step Before (HACS): v0.9.0: v0.9.0 - New Features After (HACS): v0.9.0: Multi-Home Support & Diagnostic Sensors Impact: Release titles in HACS are now cleaner with single version display and more descriptive titles generated intelligently from commit content. All three backends (copilot, git-cliff, manual) produce consistent output with H1 title followed by H3 sections. --- .github/workflows/release.yml | 33 ++++--------- scripts/generate-release-notes | 84 ++++++++++++++++++++++++++++------ 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 192ffd8..98158b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -195,6 +195,13 @@ jobs: # git-cliff will handle filtering via cliff.toml USE_AI=false ./scripts/generate-release-notes "${FROM_TAG}" "${TO_TAG}" > release-notes.md + # Extract title from release notes (first line starting with "# ") + TITLE=$(head -n 1 release-notes.md | sed 's/^# //') + if [ -z "$TITLE" ]; then + TITLE="Release Updates" + fi + echo "title=$TITLE" >> $GITHUB_OUTPUT + # Append version warning if present WARNING="${{ steps.version_check.outputs.warning }}" if [ -n "$WARNING" ]; then @@ -218,34 +225,10 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "${{ steps.version_check.outputs.warning }}" >> $GITHUB_STEP_SUMMARY - - name: Generate release title - id: release_title - run: | - TAG_VERSION="${GITHUB_REF#refs/tags/}" - FROM_TAG="${{ steps.previoustag.outputs.previous_tag }}" - - # Extract main feature types from commits - FEAT_COUNT=$(git log ${FROM_TAG}..HEAD --format="%s" --no-merges | grep -cE "^feat(\(.+\))?:" || true) - FIX_COUNT=$(git log ${FROM_TAG}..HEAD --format="%s" --no-merges | grep -cE "^fix(\(.+\))?:" || true) - - # Build title based on what changed - if [ $FEAT_COUNT -gt 0 ] && [ $FIX_COUNT -gt 0 ]; then - TITLE="$TAG_VERSION - New Features & Bug Fixes" - elif [ $FEAT_COUNT -gt 0 ]; then - TITLE="$TAG_VERSION - New Features" - elif [ $FIX_COUNT -gt 0 ]; then - TITLE="$TAG_VERSION - Bug Fixes" - else - TITLE="$TAG_VERSION" - fi - - echo "title=$TITLE" >> $GITHUB_OUTPUT - echo "Release title: $TITLE" - - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - name: ${{ steps.release_title.outputs.title }} + name: ${{ steps.release_notes.outputs.title }} body: ${{ steps.release_notes.outputs.notes }} draft: false prerelease: false diff --git a/scripts/generate-release-notes b/scripts/generate-release-notes index 1ad87ad..ac39621 100755 --- a/scripts/generate-release-notes +++ b/scripts/generate-release-notes @@ -269,6 +269,36 @@ End the output after the last release note item. Nothing more." generate_with_gitcliff() { log_info "${BLUE}==> Generating with git-cliff${NC}" + # Analyze commits to generate smart title + FROM_TAG_SHORT="${FROM_TAG}" + TO_TAG_SHORT="${TO_TAG}" + COMMITS_LOG=$(git log --pretty=format:"%s" "${FROM_TAG}..${TO_TAG}" 2>/dev/null || echo "") + + # Count user-facing changes (exclude dev/ci/docs) + FEAT_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^feat\((sensors|binary_sensor|config_flow|services|coordinator|api)\):" || true) + FIX_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^fix\((sensors|binary_sensor|config_flow|services|coordinator|api|translations)\):" || true) + PERF_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^perf\(" || true) + + # Generate intelligent title based on changes + if [ $PERF_COUNT -gt 0 ]; then + TITLE="# Performance & Reliability Improvements" + elif [ $FEAT_COUNT -gt 2 ]; then + TITLE="# New Features & Enhancements" + elif [ $FEAT_COUNT -gt 0 ] && [ $FIX_COUNT -gt 0 ]; then + TITLE="# New Features & Bug Fixes" + elif [ $FEAT_COUNT -gt 0 ]; then + TITLE="# New Features" + elif [ $FIX_COUNT -gt 2 ]; then + TITLE="# Bug Fixes & Improvements" + elif [ $FIX_COUNT -gt 0 ]; then + TITLE="# Bug Fixes" + else + TITLE="# Release Updates" + fi + + echo "$TITLE" + echo "" + # Create temporary cliff.toml if not exists if [ ! -f "cliff.toml" ]; then cat > /tmp/cliff.toml <<'EOF' @@ -325,6 +355,32 @@ generate_with_manual() { exit 0 fi + # Analyze commits to generate smart title + COMMITS_LOG=$(git log --pretty=format:"%s" "${FROM_TAG}..${TO_TAG}" 2>/dev/null || echo "") + + # Count user-facing changes (exclude dev/ci/docs) + FEAT_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^feat\((sensors|binary_sensor|config_flow|services|coordinator|api)\):" || true) + FIX_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^fix\((sensors|binary_sensor|config_flow|services|coordinator|api|translations)\):" || true) + PERF_COUNT=$(echo "$COMMITS_LOG" | grep -cE "^perf\(" || true) + + # Generate intelligent title based on changes + if [ $PERF_COUNT -gt 0 ]; then + echo "# Performance & Reliability Improvements" + elif [ $FEAT_COUNT -gt 2 ]; then + echo "# New Features & Enhancements" + elif [ $FEAT_COUNT -gt 0 ] && [ $FIX_COUNT -gt 0 ]; then + echo "# New Features & Bug Fixes" + elif [ $FEAT_COUNT -gt 0 ]; then + echo "# New Features" + elif [ $FIX_COUNT -gt 2 ]; then + echo "# Bug Fixes & Improvements" + elif [ $FIX_COUNT -gt 0 ]; then + echo "# Bug Fixes" + else + echo "# Release Updates" + fi + echo "" + # Create temporary files for each category TMPDIR=$(mktemp -d) FEAT_FILE="${TMPDIR}/feat" @@ -382,42 +438,42 @@ generate_with_manual() { # Output grouped by category if [ -s "$FEAT_FILE" ]; then - echo "## ๐ŸŽ‰ New Features" + echo "### ๐ŸŽ‰ New Features" echo "" cat "$FEAT_FILE" echo "" fi if [ -s "$FIX_FILE" ]; then - echo "## ๐Ÿ› Bug Fixes" + echo "### ๐Ÿ› Bug Fixes" echo "" cat "$FIX_FILE" echo "" fi if [ -s "$DOCS_FILE" ]; then - echo "## ๐Ÿ“š Documentation" + echo "### ๐Ÿ“š Documentation" echo "" cat "$DOCS_FILE" echo "" fi if [ -s "$REFACTOR_FILE" ]; then - echo "## ๐Ÿ”ง Maintenance & Refactoring" + echo "### ๐Ÿ”ง Maintenance & Refactoring" echo "" cat "$REFACTOR_FILE" echo "" fi if [ -s "$TEST_FILE" ]; then - echo "## ๐Ÿงช Testing" + echo "### ๐Ÿงช Testing" echo "" cat "$TEST_FILE" echo "" fi if [ -s "$OTHER_FILE" ]; then - echo "## ๐Ÿ“ Other Changes" + echo "### ๐Ÿ“ Other Changes" echo "" cat "$OTHER_FILE" echo "" @@ -525,10 +581,10 @@ else NOTES_BODY=$(cat "$TEMP_NOTES") fi -# Generate final title for GitHub release +# Generate final title for GitHub release (without version tag - HACS adds it automatically) if [ -n "$EXTRACTED_TITLE" ]; then - # AI provided a title, prepend version tag - RELEASE_TITLE="$TO_TAG - $EXTRACTED_TITLE" + # Use the extracted title from release notes (no version prefix) + RELEASE_TITLE="$EXTRACTED_TITLE" else # Fallback: Keep current title if it looks meaningful # (more than just the tag itself) @@ -541,15 +597,15 @@ else DOCS_COUNT=$(echo "$NOTES_BODY" | grep -c "^### ๐Ÿ“š Documentation" || true) if [ "$FEAT_COUNT" -gt 0 ] && [ "$FIX_COUNT" -gt 0 ]; then - RELEASE_TITLE="$TO_TAG - New Features & Bug Fixes" + RELEASE_TITLE="New Features & Bug Fixes" elif [ "$FEAT_COUNT" -gt 0 ]; then - RELEASE_TITLE="$TO_TAG - New Features" + RELEASE_TITLE="New Features" elif [ "$FIX_COUNT" -gt 0 ]; then - RELEASE_TITLE="$TO_TAG - Bug Fixes" + RELEASE_TITLE="Bug Fixes" elif [ "$DOCS_COUNT" -gt 0 ]; then - RELEASE_TITLE="$TO_TAG - Documentation Updates" + RELEASE_TITLE="Documentation Updates" else - RELEASE_TITLE="$TO_TAG - Updates" + RELEASE_TITLE="Release Updates" fi fi fi