Skip to content

Commit d7efb57

Browse files
committed
feat: update pyproject (#16)
* feat: update pyproject * chore: update conf feat: configure project release automation (#17) * feat: update pyproject * chore: update conf * feat: migrate commitizen config and enhance release workflow - Migrate Commitizen configuration from cz.json to pyproject.toml - Add PAT_TOKEN support for GitHub Actions workflow - Enhance release workflow with branch protection handling - Add pre-commit hooks installation in CI - Improve error handling and alternative push strategies - Update version to 0.1.5 and configure changelog settings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor: remove changelog file generation and simplify release workflow - Remove changelog_file configuration from pyproject.toml - Remove update_changelog_on_bump setting as it's no longer needed - Update GitHub workflow to use 'cz bump --yes' instead of 'cz bump --changelog' - Remove changelog_start_rev updates since we don't maintain changelog files - Keep changelog content generation via 'cz changelog --dry-run' for GitHub releases - Simplify commit message for version updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Signed-off-by: 拐爷&&老拐瘦 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> bump: version 0.1.5 → 0.2.0 chore: update version to 0.2.0 fix: restore workflow configuration and resolve rebase conflicts (#18) * fix: restore workflow configuration and resolve rebase conflicts - Fix pyproject.toml target-version and python_version settings - Restore ACT testing support in GitHub workflow - Restore single commit logic for version bumps - Restore update_changelog_on_bump setting for proper version detection - Fix configuration conflicts from rebase * fix: prevent sed command from corrupting other version configurations - Use more precise sed pattern to only update commitizen version - Prevent target-version and python_version from being overwritten with package version - Scope sed replacement to [tool.commitizen] section only - This resolves the root cause of configuration corruption during auto-release bump: version 0.2.1 → 0.3.0
1 parent d660d8b commit d7efb57

File tree

5 files changed

+124
-41
lines changed

5 files changed

+124
-41
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
26-
token: ${{ secrets.GITHUB_TOKEN }}
26+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
2727

2828
- name: Set up Python
2929
uses: actions/setup-python@v5
@@ -33,26 +33,87 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install commitizen build twine
36+
pip install commitizen build twine pre-commit ruff mypy
3737
3838
- name: Configure Git
3939
run: |
4040
git config --local user.email "[email protected]"
4141
git config --local user.name "GitHub Action"
4242
43+
- name: Install pre-commit hooks
44+
run: |
45+
# Skip pre-commit installation during local act testing
46+
if [[ "${ACT:-false}" == "true" ]]; then
47+
echo "Skipping pre-commit setup in act environment"
48+
git config --global init.templateDir ""
49+
else
50+
pre-commit install
51+
fi
52+
53+
- name: Check branch protection status
54+
id: branch-protection
55+
run: |
56+
# Check if we can push directly to main
57+
if git push --dry-run origin main 2>/dev/null; then
58+
echo "can_push_directly=true" >> $GITHUB_OUTPUT
59+
echo "Branch allows direct push"
60+
else
61+
echo "can_push_directly=false" >> $GITHUB_OUTPUT
62+
echo "Branch is protected, will need special handling"
63+
fi
64+
4365
- name: Bump version automatically
4466
id: bump-version
4567
run: |
4668
# Check if we need to bump version based on conventional commits
47-
if cz bump --dry-run --changelog 2>/dev/null; then
69+
if cz bump --dry-run 2>/dev/null; then
4870
echo "bump_needed=true" >> $GITHUB_OUTPUT
49-
cz bump --changelog --yes
50-
git push origin main --follow-tags
71+
72+
# Get the new version that would be created
73+
NEW_VERSION=$(cz bump --dry-run | grep "bump: version" | sed 's/.*→ //')
74+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
75+
76+
# Update only the commitizen version configuration before bumping
77+
sed -i.bak "/^\[tool\.commitizen\]/,/^\[/ s/^version = \"[^\"]*\"/version = \"$NEW_VERSION\"/" pyproject.toml
78+
rm -f pyproject.toml.bak
79+
80+
# Now run cz bump which will create a single commit with all changes
81+
cz bump --yes
82+
83+
# Generate changelog content for release (without creating file)
84+
CHANGELOG_CONTENT=$(cz changelog --dry-run)
85+
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
86+
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
87+
echo "EOF" >> $GITHUB_OUTPUT
88+
89+
# Push based on branch protection status
90+
if [ "${{ steps.branch-protection.outputs.can_push_directly }}" = "true" ]; then
91+
echo "Pushing directly to main branch..."
92+
git push origin main --follow-tags
93+
else
94+
echo "Branch is protected, using alternative push strategy..."
95+
# Try with different authentication methods
96+
git push origin main --follow-tags || {
97+
echo "Standard push failed, trying with force-with-lease..."
98+
git push origin main --follow-tags --force-with-lease || {
99+
echo "All push attempts failed. This might be due to branch protection rules."
100+
echo "Please check repository settings or use a Personal Access Token (PAT_TOKEN)."
101+
echo "You can also temporarily disable branch protection for releases."
102+
exit 1
103+
}
104+
}
105+
fi
51106
else
52107
echo "bump_needed=false" >> $GITHUB_OUTPUT
53108
echo "No version bump needed based on commit messages"
54109
fi
55110
111+
- name: Display changelog content
112+
if: steps.bump-version.outputs.bump_needed == 'true'
113+
run: |
114+
echo "Generated changelog content:"
115+
echo "${{ steps.bump-version.outputs.changelog_content }}"
116+
56117
- name: Get version
57118
id: version
58119
run: |
@@ -88,14 +149,19 @@ jobs:
88149
tag_name: ${{ steps.version.outputs.tag }}
89150
name: Release ${{ steps.version.outputs.tag }}
90151
body: |
91-
## Changes in ${{ steps.version.outputs.tag }}
92-
93-
See [CHANGELOG.md](https://github.com/ai-shifu/markdown-flow-agent-py/blob/main/CHANGELOG.md) for detailed changes.
152+
${{ steps.bump-version.outputs.changelog_content }}
94153
95154
## Installation
96155
```bash
97156
pip install markdown-flow==${{ steps.version.outputs.version }}
98157
```
158+
159+
## What's Changed
160+
This release includes the following changes:
161+
- Automated version management with Commitizen
162+
- Enhanced GitHub Actions workflow for releases
163+
- Improved branch protection handling
164+
- Streamlined changelog generation
99165
files: |
100166
dist/*
101167
draft: false

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## v0.3.0 (2025-09-03)
2+
3+
### Fix
4+
5+
- restore workflow configuration and resolve rebase conflicts (#18)
6+
7+
## v0.2.0 (2025-09-03)
8+
9+
### Feat
10+
11+
- configure project release automation (#17)
12+
13+
## v0.1.5 (2025-09-03)
14+
15+
### Feat
16+
17+
- update pyproject (#16)
18+
- update commitizen config for auto release (#15)
19+
- udpate cz conf to auto release
20+
- add automated release workflow with version management (#11)
21+
- add markdownlint integration for consistent documentation quality (#10)
22+
- add markdownlint integration for consistent documentation quality (#10)
23+
- add editorconfig focused on Python backend development (#8)
24+
- add commitizen configuration for automated version management (#6)
25+
- interactive syntax escape (#3)
26+
27+
### Fix
28+
29+
- variable parsing processing in interaction (#2)

cz.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

markdown_flow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@
8282
]
8383

8484
# Version information
85-
__version__ = "0.1.5"
85+
__version__ = "0.2.0"

pyproject.toml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,24 @@ disallow_incomplete_defs = false
144144
# =============================================================================
145145
[tool.commitizen]
146146
name = "cz_conventional_commits"
147-
tag_format = "v$version"
148-
version_scheme = "semver"
149-
version_provider = "pep621"
147+
version = "0.3.0"
148+
tag_format = "v$major.$minor.$patch"
150149
update_changelog_on_bump = true
151-
major_version_zero = true
150+
annotated_tag = true
151+
gpg_sign = false
152+
version_files = [
153+
"markdown_flow/__init__.py:__version__"
154+
]
155+
bump_message = "bump: version $current_version → $new_version"
156+
style = [
157+
["qmark", "fg:#ff9d00 bold"],
158+
["question", "bold"],
159+
["answer", "fg:#ff9d00 bold"],
160+
["pointer", "fg:#ff9d00 bold"],
161+
["highlighted", "fg:#ff9d00 bold"],
162+
["selected", "fg:#cc5454"],
163+
["separator", "fg:#cc5454"],
164+
["instruction", ""],
165+
["text", ""],
166+
["disabled", "fg:#858585 italic"]
167+
]

0 commit comments

Comments
 (0)