Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .agent/skills/gh-release/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: gh-release
description: Automates version bumping in pyproject.toml and creating GitHub releases. Use when releasing a new version of the project.
---

# GitHub Release Skill

## Overview

This skill automates the process of creating a new release for this Python project. It updates the `version` in `pyproject.toml`, commits the change, and then creates a GitHub release using the `gh` CLI tool.

## Semantic Versioning (SemVer)

This project follows [Semantic Versioning](https://semver.org/) (SemVer) for releasing versions. SemVer uses a `MAJOR.MINOR.PATCH` format:

- **MAJOR** version when you make incompatible API changes.
- **MINOR** version when you add functionality in a backward compatible manner.
- **PATCH** version when you make backward compatible bug fixes.

Example: `1.0.0` -> `1.1.0` (new feature), `1.1.0` -> `1.1.1` (bug fix), `1.1.1` -> `2.0.0` (breaking change).

## Usage

To use this skill, execute the `create-release.sh` script from the root of your project with the desired new version number as an argument.

**Example:**

```bash
.agent/skills/gh-release/scripts/create-release.sh 0.9.1
```

This will perform the following actions:

1. Ensure the working directory is clean and in the `main` branch.
2. Update the `version` field in `pyproject.toml` to `0.9.1`.
3. Stage the `pyproject.toml` file.
4. Commit the change with the message `chore(release): 0.9.1`.
5. Push the changes to the `main` branch.
6. Create a GitHub release named `0.9.1` with auto-generated release notes using `gh release create "0.9.1" --generate-notes`.

## Requirements

- `gh` CLI tool must be installed and authenticated.
- The script should be run from the root of the project repository.
- The script expects to find `pyproject.toml` in the root.

## Resources

### scripts/

- `create-release.sh`: The main script that performs the release automation.
45 changes: 45 additions & 0 deletions .agent/skills/gh-release/scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -e

VERSION=$1
if [ -z "$VERSION" ]; then
echo "Usage: $0 <version>"
exit 1
fi

BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" != "main" ]]; then
echo "Error: You must be on the main branch to create a release."
exit 1
fi

if [[ -n $(git status -s) ]]; then
echo "Error: Working directory is not clean. Please commit or stash your changes."
exit 1
fi

if ! command -v gh &> /dev/null; then
echo "gh command could not be found, please install it first"
exit 1
fi

FILE_PATH="pyproject.toml"

if [ ! -f "$FILE_PATH" ]; then
echo "Error: $FILE_PATH not found."
exit 1
fi

# Update version in pyproject.toml using sed
# This assumes the format: version = "X.Y.Z"
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS requires an empty string argument for -i
sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" "$FILE_PATH"
else
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" "$FILE_PATH"
fi

git add "$FILE_PATH"
git commit -m "chore(release): $VERSION"
git push
gh release create "$VERSION" --generate-notes
5 changes: 3 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/allenporter/cookiecutter-python",
"commit": "285470c00d43779a0dca3f1cc2009c658e294443",
"commit": "7b0ca516ce7cdbd4685c3dccb0542ead46c75b02",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -10,7 +10,8 @@
"project_name": "supernote",
"description": "Unofficial python library for parsing Supernote notebooks",
"version": "0.0.1",
"_template": "https://github.com/allenporter/cookiecutter-python"
"_template": "https://github.com/allenporter/cookiecutter-python",
"_commit": "7b0ca516ce7cdbd4685c3dccb0542ead46c75b02"
}
},
"directory": null
Expand Down