diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9016b05..ee0ff7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,21 +62,50 @@ 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 - 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 @@ -180,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 @@ -199,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/CHANGELOG.md b/CHANGELOG.md index c4583db..5cc314d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,20 +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 - Initial implementation of sprout CLI tool - `create` command to create new git worktrees with Docker Compose support @@ -34,15 +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/v1.0.0...HEAD -[1.0.0]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD +[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 721657f..cefce97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "sprout-cli" -version = "1.0.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"] @@ -54,7 +57,7 @@ include = [ ] [tool.ruff] -target-version = "1.0.0" +target-version = "py313" line-length = 100 [tool.ruff.lint] @@ -67,6 +70,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 +102,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 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"