Release python package

From sequenzia/agent-alchemy · View interactive version

Release python package is an AI agent skill from the GitHub repository sequenzia/agent-alchemy. Prepare and execute a Python package release with verification steps. Use for releasing Python packages with uv and ruff.

How to use this skill

Skill file

Python Release Manager

Execute a complete pre-release workflow for Python packages using uv and ruff. This command automates version calculation, changelog updates, and tag creation.

Arguments

Workflow

Execute these 9 steps in order. Fail fast: Stop immediately if any verification step fails.


Step 1: Pre-flight Checks

Run these checks and stop if any fail:

# Check current branch
git branch --show-current
# Check for uncommitted changes
git status --porcelain
# Pull latest changes
git pull origin main

Step 2: Run Tests

Execute the test suite:

uv run pytest

Step 3: Run Linting

Execute linting checks:

uv run ruff check
uv run ruff format --check

Step 4: Verify Build

Build the package:

uv build

Step 5: Changelog Update Check

All verification checks have passed. Before calculating the version, offer to run the changelog-manager agent to ensure the [Unreleased] section is up-to-date.

Prompt the user:

Would you like to run the changelog-manager to update CHANGELOG.md before proceeding?

This will analyze git commits since the last release and suggest new changelog entries.

If user selects "Yes":

Spawn a changelog-manager sub-agent with the prompt: "Analyze commits since the last release and update the CHANGELOG.md [Unreleased] section"

Wait for the agent to complete before proceeding.

If user selects "No":

Continue to Step 6 (Calculate Version) without running the changelog-manager.


Step 6: Calculate Version

6.1 Read CHANGELOG.md

Read CHANGELOG.md and parse its structure. Look for:

6.2 Analyze Change Types

Count entries under [Unreleased] by subsection:

6.3 Calculate Suggested Version

Apply semantic versioning rules to the current version (MAJOR.MINOR.PATCH):

| Condition | Bump Type | Example |

|-----------|-----------|---------|

| ### Removed present AND current >= 1.0.0 | MAJOR | 1.2.3 -> 2.0.0 |

| ### Removed present AND current < 1.0.0 | MINOR | 0.2.3 -> 0.3.0 |

| ### Added or ### Changed present | MINOR | 0.1.0 -> 0.2.0 |

| Only ### Fixed, ### Security, or ### Deprecated | PATCH | 0.1.0 -> 0.1.1 |

6.4 Handle Edge Cases
6.5 User Confirmation

Prompt the user to confirm the version:

Based on changelog analysis:

- Found: {count} Added, {count} Changed, {count} Fixed, {count} Removed entries

- Current version: {current}

- Suggested version: {suggested} ({bump_type} bump)

Confirm version or provide override:


Step 7: Update CHANGELOG.md

7.1 Get Repository URL

Read pyproject.toml and extract the repository URL from [project.urls]:

If no repository URL found, warn but continue (comparison links will be omitted).

7.2 Update Changelog Content

Transform the changelog:

Before:

## [Unreleased]

### Added
- New feature X

## [0.1.0] - 2024-01-15

### Added
- Initial release

[Unreleased]: https://github.com/user/repo/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/user/repo/releases/tag/v0.1.0

After (releasing 0.2.0):

## [Unreleased]

## [0.2.0] - {today's date YYYY-MM-DD}

### Added
- New feature X

## [0.1.0] - 2024-01-15

### Added
- Initial release

[Unreleased]: https://github.com/user/repo/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/user/repo/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/user/repo/releases/tag/v0.1.0
7.3 Write Updated CHANGELOG.md

Update CHANGELOG.md with the transformed content.


Step 8: Commit Changelog

Stage and commit the changelog update:

git add CHANGELOG.md
git commit -m "docs: update changelog for v{version}"
git push origin main

Report: "Changelog committed and pushed"


Step 9: Create and Push Tag

Create an annotated tag and push it:

git tag -a v{version} -m "Release v{version}"
git push origin v{version}
Final Report

Report success with details:

Release v{version} completed successfully!

- Changelog updated: CHANGELOG.md
- Tag created: v{version}
- Tag URL: {repository_url}/releases/tag/v{version}

Next steps:
- GitHub/GitLab will create a release from the tag
- Publish to PyPI if configured in CI

Error Recovery

If any step fails after Step 6 (version confirmation):


Integration Notes

What this component does: Orchestrates a complete Python package release workflow: pre-flight checks (branch, clean working directory), test suite, linting, build verification, changelog analysis, semantic version calculation, changelog update, commit, and tag creation.

Capabilities needed: Shell execution (git, uv, ruff commands), file reading/editing (CHANGELOG.md, pyproject.toml), user interaction (version confirmation, changelog update prompt), sub-agent spawning (changelog-manager).

Adaptation guidance: The workflow assumes uv for Python package management and ruff for linting. Adapt tool commands if using different tooling. The changelog-manager sub-agent handles changelog entry generation.

Sub-agent capabilities: The changelog-manager agent analyzes git history and updates CHANGELOG.md entries. It needs shell execution (git commands), file reading/editing, and user interaction.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.