Skip to content

Commit c472e9e

Browse files
authored
Merge pull request #42 from allenporter/cruft/update
New updates detected with Cruft
2 parents dc5b8fc + a58c837 commit c472e9e

3 files changed

Lines changed: 99 additions & 2 deletions

File tree

.agent/skills/gh-release/SKILL.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: gh-release
3+
description: Automates version bumping in pyproject.toml and creating GitHub releases. Use when releasing a new version of the project.
4+
---
5+
6+
# GitHub Release Skill
7+
8+
## Overview
9+
10+
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.
11+
12+
## Semantic Versioning (SemVer)
13+
14+
This project follows [Semantic Versioning](https://semver.org/) (SemVer) for releasing versions. SemVer uses a `MAJOR.MINOR.PATCH` format:
15+
16+
- **MAJOR** version when you make incompatible API changes.
17+
- **MINOR** version when you add functionality in a backward compatible manner.
18+
- **PATCH** version when you make backward compatible bug fixes.
19+
20+
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).
21+
22+
## Usage
23+
24+
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.
25+
26+
**Example:**
27+
28+
```bash
29+
.agent/skills/gh-release/scripts/create-release.sh 0.9.1
30+
```
31+
32+
This will perform the following actions:
33+
34+
1. Ensure the working directory is clean and in the `main` branch.
35+
2. Update the `version` field in `pyproject.toml` to `0.9.1`.
36+
3. Stage the `pyproject.toml` file.
37+
4. Commit the change with the message `chore(release): 0.9.1`.
38+
5. Push the changes to the `main` branch.
39+
6. Create a GitHub release named `0.9.1` with auto-generated release notes using `gh release create "0.9.1" --generate-notes`.
40+
41+
## Requirements
42+
43+
- `gh` CLI tool must be installed and authenticated.
44+
- The script should be run from the root of the project repository.
45+
- The script expects to find `pyproject.toml` in the root.
46+
47+
## Resources
48+
49+
### scripts/
50+
51+
- `create-release.sh`: The main script that performs the release automation.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION=$1
5+
if [ -z "$VERSION" ]; then
6+
echo "Usage: $0 <version>"
7+
exit 1
8+
fi
9+
10+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
11+
if [[ "$BRANCH" != "main" ]]; then
12+
echo "Error: You must be on the main branch to create a release."
13+
exit 1
14+
fi
15+
16+
if [[ -n $(git status -s) ]]; then
17+
echo "Error: Working directory is not clean. Please commit or stash your changes."
18+
exit 1
19+
fi
20+
21+
if ! command -v gh &> /dev/null; then
22+
echo "gh command could not be found, please install it first"
23+
exit 1
24+
fi
25+
26+
FILE_PATH="pyproject.toml"
27+
28+
if [ ! -f "$FILE_PATH" ]; then
29+
echo "Error: $FILE_PATH not found."
30+
exit 1
31+
fi
32+
33+
# Update version in pyproject.toml using sed
34+
# This assumes the format: version = "X.Y.Z"
35+
if [[ "$OSTYPE" == "darwin"* ]]; then
36+
# macOS requires an empty string argument for -i
37+
sed -i '' "s/^version = \".*\"/version = \"$VERSION\"/" "$FILE_PATH"
38+
else
39+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" "$FILE_PATH"
40+
fi
41+
42+
git add "$FILE_PATH"
43+
git commit -m "chore(release): $VERSION"
44+
git push
45+
gh release create "$VERSION" --generate-notes

.cruft.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "http://github.com/allenporter/cookiecutter-python",
3-
"commit": "285470c00d43779a0dca3f1cc2009c658e294443",
3+
"commit": "7b0ca516ce7cdbd4685c3dccb0542ead46c75b02",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -10,7 +10,8 @@
1010
"project_name": "nano_gpt",
1111
"description": "A GPT-2 reproduction following karpathy's nanoGPT youtube videos",
1212
"version": "0.0.1",
13-
"_template": "http://github.com/allenporter/cookiecutter-python"
13+
"_template": "http://github.com/allenporter/cookiecutter-python",
14+
"_commit": "7b0ca516ce7cdbd4685c3dccb0542ead46c75b02"
1415
}
1516
},
1617
"directory": null

0 commit comments

Comments
 (0)