Skip to content

Commit 1541903

Browse files
authored
Merge pull request #3 from SecDev-Lab/release-ci
fix: Fix release workflow version detection logic
2 parents fda3e42 + 62723a9 commit 1541903

File tree

4 files changed

+51
-44
lines changed

4 files changed

+51
-44
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,50 @@ jobs:
6262
- name: Determine version bump type
6363
id: version
6464
run: |
65-
# Extract current version from pyproject.toml
66-
current_version=$(grep -E '^version = "' pyproject.toml | cut -d'"' -f2)
65+
# Extract current version from __init__.py
66+
current_version=$(grep -E '^__version__ = "' src/sprout/__init__.py | cut -d'"' -f2)
6767
echo "Current version: $current_version"
6868
6969
# Analyze changelog to determine bump type
70-
major_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Removed)" || true)
71-
minor_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Added|Changed|Deprecated)" || true)
72-
patch_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Fixed|Security)" || true)
70+
# Extract the Unreleased section
71+
unreleased_section=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md)
7372
74-
# Determine bump type (check in order: major -> minor -> patch)
75-
if [ -n "$major_changes" ]; then
73+
# Check for sections with actual entries (lines starting with -)
74+
major_entries=""
75+
minor_entries=""
76+
patch_entries=""
77+
78+
# Check if Removed section has entries
79+
if echo "$unreleased_section" | grep -q "^### Removed"; then
80+
major_entries=$(echo "$unreleased_section" | sed -n '/### Removed/,/^###\|^##/p' | grep "^- " || true)
81+
fi
82+
83+
# Check if Added/Changed/Deprecated sections have entries
84+
for section in "Added" "Changed" "Deprecated"; do
85+
if echo "$unreleased_section" | grep -q "^### $section"; then
86+
section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true)
87+
if [ -n "$section_entries" ]; then
88+
minor_entries="$minor_entries$section_entries"
89+
fi
90+
fi
91+
done
92+
93+
# Check if Fixed/Security sections have entries
94+
for section in "Fixed" "Security"; do
95+
if echo "$unreleased_section" | grep -q "^### $section"; then
96+
section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true)
97+
if [ -n "$section_entries" ]; then
98+
patch_entries="$patch_entries$section_entries"
99+
fi
100+
fi
101+
done
102+
103+
# Determine bump type based on actual entries
104+
if [ -n "$major_entries" ]; then
76105
bump_type="major"
77-
elif [ -n "$minor_changes" ]; then
106+
elif [ -n "$minor_entries" ]; then
78107
bump_type="minor"
79-
elif [ -n "$patch_changes" ]; then
108+
elif [ -n "$patch_entries" ]; then
80109
bump_type="patch"
81110
else
82111
# Default to patch if only individual items without category
@@ -180,10 +209,7 @@ jobs:
180209
181210
- name: Update version in files
182211
run: |
183-
# Update pyproject.toml
184-
sed -i 's/version = ".*"/version = "${{ needs.prepare-release.outputs.version }}"/' pyproject.toml
185-
186-
# Update __init__.py
212+
# Update __init__.py (pyproject.toml reads version from here dynamically)
187213
sed -i 's/__version__ = ".*"/__version__ = "${{ needs.prepare-release.outputs.version }}"/' src/sprout/__init__.py
188214
189215
# Update CHANGELOG.md
@@ -199,7 +225,7 @@ jobs:
199225
run: |
200226
git config --local user.email "action@github.com"
201227
git config --local user.name "GitHub Action"
202-
git add pyproject.toml src/sprout/__init__.py CHANGELOG.md
228+
git add src/sprout/__init__.py CHANGELOG.md
203229
git commit -m "Release version ${{ needs.prepare-release.outputs.version }}"
204230
205231
- name: Build package

CHANGELOG.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Added
11-
12-
### Changed
13-
14-
### Deprecated
15-
16-
### Removed
17-
18-
### Fixed
19-
20-
### Security
21-
22-
## [1.0.0] - 2025-06-27
23-
2410
### Added
2511
- Initial implementation of sprout CLI tool
2612
- `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
3420
- CI/CD pipeline with GitHub Actions
3521
- Support for Python 3.11, 3.12, and 3.13
3622

37-
### Changed
38-
39-
### Deprecated
40-
41-
### Removed
42-
43-
### Fixed
44-
45-
### Security
46-
47-
[Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD
48-
[1.0.0]: https://github.com/SecDev-Lab/sprout/compare/v1.0.0...HEAD
23+
[Unreleased]: https://github.com/SecDev-Lab/sprout/compare/v0.1.0...HEAD

pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "sprout-cli"
7-
version = "1.0.0"
7+
dynamic = ["version"]
88
description = "CLI tool to automate git worktree and Docker Compose development workflows"
99
readme = "README.md"
1010
requires-python = ">=3.11"
@@ -41,6 +41,9 @@ dev = [
4141
[project.scripts]
4242
sprout = "sprout.__main__:main"
4343

44+
[tool.hatch.version]
45+
path = "src/sprout/__init__.py"
46+
4447
[tool.hatch.build.targets.wheel]
4548
packages = ["src/sprout"]
4649

@@ -54,7 +57,7 @@ include = [
5457
]
5558

5659
[tool.ruff]
57-
target-version = "1.0.0"
60+
target-version = "py313"
5861
line-length = 100
5962

6063
[tool.ruff.lint]
@@ -67,6 +70,9 @@ select = [
6770
"C4", # flake8-comprehensions
6871
"UP", # pyupgrade
6972
]
73+
ignore = [
74+
"UP040", # TypeAlias annotations - not compatible with typer
75+
]
7076

7177
[tool.ruff.lint.per-file-ignores]
7278
"tests/*" = ["S101", "S103"]
@@ -96,7 +102,7 @@ exclude_lines = [
96102
]
97103

98104
[tool.mypy]
99-
python_version = "1.0.0"
105+
python_version = "3.11"
100106
warn_return_any = true
101107
warn_unused_configs = true
102108
disallow_untyped_defs = true

src/sprout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""sprout - CLI tool to automate git worktree and Docker Compose development workflows."""
22

3-
__version__ = "1.0.0"
3+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)