Skip to content

Commit bdf41a5

Browse files
Merge pull request #18 from Maciek-roboblog/uv
Add package manager & Update build process & Update npm lib process installation
2 parents 48f64d6 + 29142b9 commit bdf41a5

19 files changed

+2368
-660
lines changed

.coderabbit.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
language: "en-US"
3+
early_access: false
4+
reviews:
5+
profile: "chill"
6+
request_changes_workflow: false
7+
high_level_summary: true
8+
poem: true
9+
review_status: true
10+
collapse_walkthrough: false
11+
auto_review:
12+
enabled: true
13+
drafts: false
14+
chat:
15+
auto_reply: true

.github/workflows/lint.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
name: Lint with Ruff
13+
strategy:
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v4
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: uv sync --extra dev
29+
30+
- name: Run Ruff linter
31+
run: uv run ruff check --output-format=github .
32+
33+
- name: Run Ruff formatter
34+
run: uv run ruff format --check .
35+
36+
pre-commit:
37+
runs-on: ubuntu-latest
38+
name: Pre-commit hooks
39+
strategy:
40+
matrix:
41+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v4
47+
with:
48+
version: "latest"
49+
50+
- name: Set up Python ${{ matrix.python-version }}
51+
run: uv python install ${{ matrix.python-version }}
52+
53+
- name: Install pre-commit
54+
run: uv tool install pre-commit --with pre-commit-uv
55+
56+
- name: Run pre-commit
57+
run: |
58+
# Run pre-commit and check if any files would be modified
59+
uv tool run pre-commit run --all-files --show-diff-on-failure || (
60+
echo "Pre-commit hooks would modify files. Please run 'pre-commit run --all-files' locally and commit the changes."
61+
exit 1
62+
)

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-version:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should_release: ${{ steps.check.outputs.should_release }}
13+
version: ${{ steps.extract.outputs.version }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Extract version from pyproject.toml
20+
id: extract
21+
run: |
22+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
23+
echo "version=$VERSION" >> $GITHUB_OUTPUT
24+
echo "Version: $VERSION"
25+
26+
- name: Check if tag exists
27+
id: check
28+
run: |
29+
VERSION="${{ steps.extract.outputs.version }}"
30+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
31+
echo "Tag v$VERSION already exists"
32+
echo "should_release=false" >> $GITHUB_OUTPUT
33+
else
34+
echo "Tag v$VERSION does not exist"
35+
echo "should_release=true" >> $GITHUB_OUTPUT
36+
fi
37+
38+
release:
39+
needs: check-version
40+
if: needs.check-version.outputs.should_release == 'true'
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write
44+
id-token: write # For trusted PyPI publishing
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v4
52+
with:
53+
version: "latest"
54+
55+
- name: Set up Python
56+
run: uv python install
57+
58+
- name: Extract changelog for version
59+
id: changelog
60+
run: |
61+
VERSION="${{ needs.check-version.outputs.version }}"
62+
echo "Extracting changelog for version $VERSION"
63+
64+
# Extract the changelog section for this version
65+
awk -v ver="## [$VERSION]" '
66+
BEGIN { found=0 }
67+
$0 ~ ver { found=1; next }
68+
found && /^## \[/ { exit }
69+
found { print }
70+
' CHANGELOG.md > release_notes.md
71+
72+
# If no changelog found, create a simple message
73+
if [ ! -s release_notes.md ]; then
74+
echo "No specific changelog found for version $VERSION" > release_notes.md
75+
fi
76+
77+
echo "Release notes:"
78+
cat release_notes.md
79+
80+
- name: Create git tag
81+
run: |
82+
VERSION="${{ needs.check-version.outputs.version }}"
83+
git config user.name "GitHub Actions"
84+
git config user.email "[email protected]"
85+
git tag -a "v$VERSION" -m "Release v$VERSION"
86+
git push origin "v$VERSION"
87+
88+
- name: Create GitHub Release
89+
uses: softprops/action-gh-release@v2
90+
with:
91+
tag_name: v${{ needs.check-version.outputs.version }}
92+
name: Release v${{ needs.check-version.outputs.version }}
93+
body_path: release_notes.md
94+
draft: false
95+
prerelease: false
96+
97+
- name: Build package
98+
run: |
99+
uv build
100+
ls -la dist/
101+
102+
- name: Publish to PyPI
103+
uses: pypa/gh-action-pypi-publish@release/v1
104+
with:
105+
skip-existing: true
106+
107+
notify-success:
108+
needs: [check-version, release]
109+
if: needs.check-version.outputs.should_release == 'true' && success()
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Success notification
113+
run: |
114+
echo "🎉 Successfully released v${{ needs.check-version.outputs.version }}!"
115+
echo "- GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${{ needs.check-version.outputs.version }}"
116+
echo "- PyPI: https://pypi.org/project/claude-monitor/${{ needs.check-version.outputs.version }}/"

.github/workflows/version-bump.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Version Bump Helper
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump_type:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
changelog_entry:
16+
description: 'Changelog entry (brief description of changes)'
17+
required: true
18+
type: string
19+
20+
jobs:
21+
bump-version:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v4
34+
with:
35+
version: "latest"
36+
37+
- name: Set up Python
38+
run: uv python install
39+
40+
- name: Extract current version
41+
id: current
42+
run: |
43+
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
44+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
45+
echo "Current version: $CURRENT_VERSION"
46+
47+
- name: Calculate new version
48+
id: new
49+
run: |
50+
CURRENT="${{ steps.current.outputs.version }}"
51+
BUMP_TYPE="${{ github.event.inputs.bump_type }}"
52+
53+
# Split version into components
54+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
55+
56+
# Bump according to type
57+
case "$BUMP_TYPE" in
58+
major)
59+
MAJOR=$((MAJOR + 1))
60+
MINOR=0
61+
PATCH=0
62+
;;
63+
minor)
64+
MINOR=$((MINOR + 1))
65+
PATCH=0
66+
;;
67+
patch)
68+
PATCH=$((PATCH + 1))
69+
;;
70+
esac
71+
72+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
73+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
74+
echo "New version: $NEW_VERSION"
75+
76+
- name: Update pyproject.toml
77+
run: |
78+
NEW_VERSION="${{ steps.new.outputs.version }}"
79+
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml
80+
echo "Updated pyproject.toml to version $NEW_VERSION"
81+
82+
- name: Update CHANGELOG.md
83+
run: |
84+
NEW_VERSION="${{ steps.new.outputs.version }}"
85+
TODAY=$(date +%Y-%m-%d)
86+
CHANGELOG_ENTRY="${{ github.event.inputs.changelog_entry }}"
87+
88+
# Create new changelog section
89+
echo "## [$NEW_VERSION] - $TODAY" > changelog_new.md
90+
echo "" >> changelog_new.md
91+
echo "### Changed" >> changelog_new.md
92+
echo "- $CHANGELOG_ENTRY" >> changelog_new.md
93+
echo "" >> changelog_new.md
94+
95+
# Find the line number where we should insert (after the # Changelog header)
96+
LINE_NUM=$(grep -n "^# Changelog" CHANGELOG.md | head -1 | cut -d: -f1)
97+
98+
if [ -n "$LINE_NUM" ]; then
99+
# Insert after the Changelog header and empty line
100+
head -n $((LINE_NUM + 1)) CHANGELOG.md > changelog_temp.md
101+
cat changelog_new.md >> changelog_temp.md
102+
tail -n +$((LINE_NUM + 2)) CHANGELOG.md >> changelog_temp.md
103+
mv changelog_temp.md CHANGELOG.md
104+
else
105+
# If no header found, prepend to file
106+
cat changelog_new.md CHANGELOG.md > changelog_temp.md
107+
mv changelog_temp.md CHANGELOG.md
108+
fi
109+
110+
# Add the version link at the bottom
111+
echo "" >> CHANGELOG.md
112+
echo "[$NEW_VERSION]: https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor/releases/tag/v$NEW_VERSION" >> CHANGELOG.md
113+
114+
echo "Updated CHANGELOG.md with new version entry"
115+
116+
- name: Create Pull Request
117+
uses: peter-evans/create-pull-request@v6
118+
with:
119+
token: ${{ secrets.GITHUB_TOKEN }}
120+
commit-message: "Bump version to ${{ steps.new.outputs.version }}"
121+
title: "chore: bump version to ${{ steps.new.outputs.version }}"
122+
body: |
123+
## Version Bump: ${{ steps.current.outputs.version }} → ${{ steps.new.outputs.version }}
124+
125+
**Bump Type**: ${{ github.event.inputs.bump_type }}
126+
127+
**Changes**: ${{ github.event.inputs.changelog_entry }}
128+
129+
This PR was automatically created by the Version Bump workflow.
130+
131+
### Checklist
132+
- [ ] Review the version bump in `pyproject.toml`
133+
- [ ] Review the changelog entry in `CHANGELOG.md`
134+
- [ ] Merge this PR to trigger the release workflow
135+
branch: version-bump-${{ steps.new.outputs.version }}
136+
delete-branch: true
137+
labels: |
138+
version-bump
139+
automated

0 commit comments

Comments
 (0)