From 6b7db3c3ee05427a6fcc210aee87b138a6cd60e5 Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Fri, 27 Jun 2025 12:31:52 +0900 Subject: [PATCH 1/5] fix: Fix release workflow to only check for actual entries in changelog sections - Fixed version bump logic to check for actual entries (lines starting with '-') instead of just checking for section headers - Removed empty changelog sections that were causing incorrect major version bump - Now correctly detects that only Added section has entries, resulting in minor bump --- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++------ CHANGELOG.md | 10 -------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9016b05..989306d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,16 +67,45 @@ jobs: echo "Current version: $current_version" # Analyze changelog to determine bump type - major_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Removed)" || true) - minor_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Added|Changed|Deprecated)" || true) - patch_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Fixed|Security)" || true) + # Extract the Unreleased section + unreleased_section=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md) - # Determine bump type (check in order: major -> minor -> patch) - if [ -n "$major_changes" ]; then + # Check for sections with actual entries (lines starting with -) + major_entries="" + minor_entries="" + patch_entries="" + + # Check if Removed section has entries + if echo "$unreleased_section" | grep -q "^### Removed"; then + major_entries=$(echo "$unreleased_section" | sed -n '/### Removed/,/^###\|^##/p' | grep "^- " || true) + fi + + # Check if Added/Changed/Deprecated sections have entries + for section in "Added" "Changed" "Deprecated"; do + if echo "$unreleased_section" | grep -q "^### $section"; then + section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true) + if [ -n "$section_entries" ]; then + minor_entries="$minor_entries$section_entries" + fi + fi + done + + # Check if Fixed/Security sections have entries + for section in "Fixed" "Security"; do + if echo "$unreleased_section" | grep -q "^### $section"; then + section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true) + if [ -n "$section_entries" ]; then + patch_entries="$patch_entries$section_entries" + fi + fi + done + + # Determine bump type based on actual entries + if [ -n "$major_entries" ]; then bump_type="major" - elif [ -n "$minor_changes" ]; then + elif [ -n "$minor_entries" ]; then bump_type="minor" - elif [ -n "$patch_changes" ]; then + elif [ -n "$patch_entries" ]; then bump_type="patch" else # Default to patch if only individual items without category diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a153fa..5cc314d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,14 +20,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CI/CD pipeline with GitHub Actions - Support for Python 3.11, 3.12, and 3.13 -### Changed - -### Deprecated - -### Removed - -### Fixed - -### Security - [Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v0.1.0...HEAD \ No newline at end of file From 2f5015a68ef05a2f1e87f1f52b5e4723da94baff Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Fri, 27 Jun 2025 12:40:43 +0900 Subject: [PATCH 2/5] fix: Fix linting errors and configuration issues - Reverted type aliases to use TypeAlias annotation (typer compatibility) - Added UP040 to ruff ignore rules since typer doesn't support new type syntax - Fixed mypy python_version from incorrect '1.0.0' to '3.11' - Cleaned up CHANGELOG.md formatting --- CHANGELOG.md | 10 ---------- pyproject.toml | 7 +++++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4583db..6408126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,15 +34,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CI/CD pipeline with GitHub Actions - Support for Python 3.11, 3.12, and 3.13 -### Changed - -### Deprecated - -### Removed - -### Fixed - -### Security - [Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD [1.0.0]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD diff --git a/pyproject.toml b/pyproject.toml index 721657f..88c27d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ include = [ ] [tool.ruff] -target-version = "1.0.0" +target-version = "py313" line-length = 100 [tool.ruff.lint] @@ -67,6 +67,9 @@ select = [ "C4", # flake8-comprehensions "UP", # pyupgrade ] +ignore = [ + "UP040", # TypeAlias annotations - not compatible with typer +] [tool.ruff.lint.per-file-ignores] "tests/*" = ["S101", "S103"] @@ -96,7 +99,7 @@ exclude_lines = [ ] [tool.mypy] -python_version = "1.0.0" +python_version = "3.11" warn_return_any = true warn_unused_configs = true disallow_untyped_defs = true From 88d5772dfe04069dad014d9b52c8807c61cf5887 Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Fri, 27 Jun 2025 12:43:59 +0900 Subject: [PATCH 3/5] fix: Fix CHANGELOG.md format after 1.0.0 release - Moved content from Unreleased to 1.0.0 section - Removed empty subsections - Fixed version comparison links --- CHANGELOG.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408126..3dbf78b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,18 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Added - -### Changed - -### Deprecated - -### Removed - -### Fixed - -### Security - ## [1.0.0] - 2025-06-27 ### Added @@ -35,4 +23,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for Python 3.11, 3.12, and 3.13 [Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD -[1.0.0]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD +[1.0.0]: https://github.com/SecDev-Lab/sprout/releases/tag/v1.0.0 \ No newline at end of file From 74638c1127e8e00ecaaecf7e7a976d1e0e69f9e2 Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Fri, 27 Jun 2025 12:45:16 +0900 Subject: [PATCH 4/5] revert: Revert version to 0.1.0 and undo 1.0.0 release - Changed version back to 0.1.0 in pyproject.toml and __init__.py - Moved changelog entries back to Unreleased section - Removed 1.0.0 release entry from CHANGELOG.md --- CHANGELOG.md | 5 +---- pyproject.toml | 2 +- src/sprout/__init__.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dbf78b..5cc314d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [1.0.0] - 2025-06-27 - ### Added - Initial implementation of sprout CLI tool - `create` command to create new git worktrees with Docker Compose support @@ -22,5 +20,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CI/CD pipeline with GitHub Actions - Support for Python 3.11, 3.12, and 3.13 -[Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD -[1.0.0]: https://github.com/SecDev-Lab/sprout/releases/tag/v1.0.0 \ No newline at end of file +[Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v0.1.0...HEAD \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 88c27d5..1cb8874 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "sprout-cli" -version = "1.0.0" +version = "0.1.0" description = "CLI tool to automate git worktree and Docker Compose development workflows" readme = "README.md" requires-python = ">=3.11" diff --git a/src/sprout/__init__.py b/src/sprout/__init__.py index 0ec5f61..039df06 100644 --- a/src/sprout/__init__.py +++ b/src/sprout/__init__.py @@ -1,3 +1,3 @@ """sprout - CLI tool to automate git worktree and Docker Compose development workflows.""" -__version__ = "1.0.0" +__version__ = "0.1.0" From 62723a96ea07d047016fa7db2bc303e22357ab5a Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Fri, 27 Jun 2025 12:47:27 +0900 Subject: [PATCH 5/5] feat: Use dynamic versioning with hatchling - Configure hatchling to read version from src/sprout/__init__.py - Update release workflow to only update __init__.py - Remove version duplication between pyproject.toml and __init__.py --- .github/workflows/release.yml | 11 ++++------- pyproject.toml | 5 ++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 989306d..ee0ff7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,8 +62,8 @@ jobs: - name: Determine version bump type id: version run: | - # Extract current version from pyproject.toml - current_version=$(grep -E '^version = "' pyproject.toml | cut -d'"' -f2) + # Extract current version from __init__.py + current_version=$(grep -E '^__version__ = "' src/sprout/__init__.py | cut -d'"' -f2) echo "Current version: $current_version" # Analyze changelog to determine bump type @@ -209,10 +209,7 @@ jobs: - name: Update version in files run: | - # Update pyproject.toml - sed -i 's/version = ".*"/version = "${{ needs.prepare-release.outputs.version }}"/' pyproject.toml - - # Update __init__.py + # Update __init__.py (pyproject.toml reads version from here dynamically) sed -i 's/__version__ = ".*"/__version__ = "${{ needs.prepare-release.outputs.version }}"/' src/sprout/__init__.py # Update CHANGELOG.md @@ -228,7 +225,7 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add pyproject.toml src/sprout/__init__.py CHANGELOG.md + git add src/sprout/__init__.py CHANGELOG.md git commit -m "Release version ${{ needs.prepare-release.outputs.version }}" - name: Build package diff --git a/pyproject.toml b/pyproject.toml index 1cb8874..cefce97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "sprout-cli" -version = "0.1.0" +dynamic = ["version"] description = "CLI tool to automate git worktree and Docker Compose development workflows" readme = "README.md" requires-python = ">=3.11" @@ -41,6 +41,9 @@ dev = [ [project.scripts] sprout = "sprout.__main__:main" +[tool.hatch.version] +path = "src/sprout/__init__.py" + [tool.hatch.build.targets.wheel] packages = ["src/sprout"]