@@ -10,104 +10,133 @@ jobs:
1010 runs-on : ubuntu-latest
1111 permissions :
1212 contents : write
13+ id-token : write # Required for trusted publishing to PyPI
1314
1415 steps :
1516 - uses : actions/checkout@v4
1617 with :
1718 fetch-depth : 0
1819 token : ${{ secrets.GITHUB_TOKEN }}
1920
20- - name : Get current version
21- id : current
21+ - name : Get version from pyproject.toml
22+ id : version
2223 run : |
2324 VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)
2425 echo "version=$VERSION" >> $GITHUB_OUTPUT
25- echo "Current version: $VERSION"
26-
27- - name : Determine version bump
28- id : bump
29- run : |
30- COMMIT_MSG=$(git log -1 --pretty=%B)
31- echo "Commit message: $COMMIT_MSG"
32-
33- # Check if commit message indicates minor bump (feat/feature)
34- if echo "$COMMIT_MSG" | grep -qiE "^feat(\(.*\))?:|^feature(\(.*\))?:"; then
35- echo "bump=minor" >> $GITHUB_OUTPUT
36- else
37- echo "bump=patch" >> $GITHUB_OUTPUT
38- fi
39-
40- - name : Calculate new version
41- id : new
42- run : |
43- CURRENT="${{ steps.current.outputs.version }}"
44- BUMP="${{ steps.bump.outputs.bump }}"
45-
46- IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
47-
48- if [ "$BUMP" = "minor" ]; then
49- MINOR=$((MINOR + 1))
50- PATCH=0
51- else
52- PATCH=$((PATCH + 1))
53- fi
54-
55- NEW_VERSION="$MAJOR.$MINOR.$PATCH"
56- echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
57- echo "New version: $NEW_VERSION (bump: $BUMP)"
26+ echo "Version from pyproject.toml: $VERSION"
5827
5928 - name : Check if version already released
6029 id : check
6130 run : |
62- NEW_VERSION ="${{ steps.new .outputs.version }}"
63- if git tag | grep -q "^v$NEW_VERSION $"; then
31+ VERSION ="${{ steps.version .outputs.version }}"
32+ if git tag | grep -q "^v$VERSION $"; then
6433 echo "skip=true" >> $GITHUB_OUTPUT
65- echo "Version v$NEW_VERSION already exists, skipping"
34+ echo "Version v$VERSION already exists, skipping"
6635 else
6736 echo "skip=false" >> $GITHUB_OUTPUT
37+ echo "Version v$VERSION not released yet"
6838 fi
6939
70- - name : Update version in files
40+ - name : Create tag and release
7141 if : steps.check.outputs.skip == 'false'
42+ env :
43+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7244 run : |
73- NEW_VERSION="${{ steps.new.outputs.version }}"
45+ VERSION="${{ steps.version.outputs.version }}"
46+ COMMIT_MSG=$(git log -1 --pretty=%B | head -1)
7447
75- # Update pyproject.toml
76- sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
48+ git config user.name "GitHub Actions"
49+ git config user.email "actions@github.com"
50+ git tag -a "v$VERSION" -m "Release v$VERSION"
51+ git push origin "v$VERSION"
7752
78- # Update __init__.py
79- sed -i "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" src/aidocs_cli/__init__.py
53+ cat <<EOF | gh release create "v$VERSION" --title "v$VERSION" --notes-file -
54+ ## Changes
8055
81- echo "Updated version to $NEW_VERSION"
56+ $COMMIT_MSG
8257
83- - name : Commit version bump
58+ ---
59+ *Auto-generated release*
60+ EOF
61+
62+ # Publish to PyPI
63+ - name : Install uv
8464 if : steps.check.outputs.skip == 'false'
85- run : |
86- NEW_VERSION="${{ steps.new.outputs.version }}"
87- git config user.name "GitHub Actions"
88- git config user.email "actions@github.com"
89- git add pyproject.toml src/aidocs_cli/__init__.py
90- git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
91- git push
65+ uses : astral-sh/setup-uv@v4
66+ with :
67+ version : " latest"
9268
93- - name : Create tag and release
69+ - name : Set up Python
9470 if : steps.check.outputs.skip == 'false'
95- env :
96- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97- run : |
98- NEW_VERSION="${{ steps.new.outputs.version }}"
99- COMMIT_MSG=$(git log -2 --pretty=%B | tail -n +3 | head -1)
71+ run : uv python install 3.11
10072
101- # Create tag
102- git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
103- git push origin "v$NEW_VERSION"
73+ - name : Build package
74+ if : steps.check.outputs.skip == 'false'
75+ run : uv build
10476
105- # Create release
106- NOTES="## Changes
77+ - name : Publish to PyPI
78+ if : steps.check.outputs.skip == 'false'
79+ uses : pypa/gh-action-pypi-publish@release/v1
80+ with :
81+ skip-existing : true
10782
108- ${COMMIT_MSG}
83+ # Update Homebrew formula
84+ - name : Get release info for Homebrew
85+ if : steps.check.outputs.skip == 'false'
86+ id : homebrew
87+ run : |
88+ VERSION="${{ steps.version.outputs.version }}"
89+ URL="https://github.com/${{ github.repository }}/archive/refs/tags/v$VERSION.tar.gz"
90+ SHA256=$(curl -sL "$URL" | shasum -a 256 | cut -d' ' -f1)
10991
110- ---
111- *Auto-generated release*"
92+ echo "version=$VERSION" >> $GITHUB_OUTPUT
93+ echo "url=$URL" >> $GITHUB_OUTPUT
94+ echo "sha256=$SHA256" >> $GITHUB_OUTPUT
11295
113- gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --notes "$NOTES"
96+ echo "Homebrew URL: $URL"
97+ echo "Homebrew SHA256: $SHA256"
98+
99+ - name : Checkout homebrew-aidocs
100+ if : steps.check.outputs.skip == 'false'
101+ uses : actions/checkout@v4
102+ with :
103+ repository : binarcode/homebrew-aidocs
104+ token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
105+ path : homebrew-aidocs
106+
107+ - name : Update Homebrew formula
108+ if : steps.check.outputs.skip == 'false'
109+ run : |
110+ cat > homebrew-aidocs/Formula/aidocs.rb << EOF
111+ class Aidocs < Formula
112+ include Language::Python::Virtualenv
113+
114+ desc "AI-powered documentation generator CLI for Claude Code"
115+ homepage "https://github.com/binarcode/aidocs-cli"
116+ url "${{ steps.homebrew.outputs.url }}"
117+ sha256 "${{ steps.homebrew.outputs.sha256 }}"
118+ license "MIT"
119+
120+ depends_on "python@3.11"
121+
122+ def install
123+ venv = virtualenv_create(libexec, "python3.11")
124+ venv.pip_install "aidocs==${{ steps.homebrew.outputs.version }}"
125+ bin.install_symlink libexec/"bin/aidocs"
126+ end
127+
128+ test do
129+ assert_match "aidocs", shell_output("#{bin}/aidocs version")
130+ end
131+ end
132+ EOF
133+
134+ - name : Commit and push Homebrew formula
135+ if : steps.check.outputs.skip == 'false'
136+ run : |
137+ cd homebrew-aidocs
138+ git config user.name "GitHub Actions"
139+ git config user.email "actions@github.com"
140+ git add Formula/aidocs.rb
141+ git diff --staged --quiet || git commit -m "Update aidocs to ${{ steps.homebrew.outputs.version }}"
142+ git push
0 commit comments