Skip to content

Commit 8d6d4de

Browse files
committed
fix: run homebrew update after PyPI publish completes
1 parent 1e10ed7 commit 8d6d4de

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
name: Update Homebrew Formula
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_run:
5+
workflows: ["Publish to PyPI"]
6+
types: [completed]
67

78
jobs:
89
update-formula:
910
runs-on: ubuntu-latest
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1012
steps:
11-
- name: Extract version from tag
12-
id: version
13-
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
14-
15-
- name: Get release tarball SHA256
16-
id: sha256
13+
- name: Get version from PyPI
14+
id: pypi
1715
run: |
18-
SHA256=$(curl -sL "https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz" | shasum -a 256 | cut -d' ' -f1)
16+
# Wait a bit for PyPI to propagate
17+
sleep 10
18+
19+
# Get latest version and SHA256 from PyPI
20+
PYPI_JSON=$(curl -s "https://pypi.org/pypi/aidocs/json")
21+
VERSION=$(echo "$PYPI_JSON" | jq -r '.info.version')
22+
SDIST_URL=$(echo "$PYPI_JSON" | jq -r '.urls[] | select(.packagetype == "sdist") | .url')
23+
SHA256=$(echo "$PYPI_JSON" | jq -r '.urls[] | select(.packagetype == "sdist") | .digests.sha256')
24+
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
echo "url=$SDIST_URL" >> $GITHUB_OUTPUT
1927
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
2028
29+
echo "Found version: $VERSION"
30+
echo "URL: $SDIST_URL"
31+
echo "SHA256: $SHA256"
32+
2133
- name: Checkout homebrew-aidocs
2234
uses: actions/checkout@v4
2335
with:
@@ -28,29 +40,26 @@ jobs:
2840
- name: Update formula
2941
run: |
3042
cd homebrew-aidocs
31-
cat > Formula/aidocs.rb << 'EOF'
43+
cat > Formula/aidocs.rb << EOF
3244
class Aidocs < Formula
45+
include Language::Python::Virtualenv
46+
3347
desc "AI-powered documentation generator CLI for Claude Code"
3448
homepage "https://github.com/binarcode/aidocs-cli"
35-
url "https://github.com/binarcode/aidocs-cli/archive/refs/tags/${{ github.ref_name }}.tar.gz"
36-
sha256 "${{ steps.sha256.outputs.sha256 }}"
49+
url "${{ steps.pypi.outputs.url }}"
50+
sha256 "${{ steps.pypi.outputs.sha256 }}"
3751
license "MIT"
38-
head "https://github.com/binarcode/aidocs-cli.git", branch: "main"
3952
4053
depends_on "python@3.11"
4154
4255
def install
43-
python3 = "python3.11"
44-
venv = virtualenv_create(libexec, python3)
45-
46-
system libexec/"bin/pip", "install", ".", "--no-deps"
47-
system libexec/"bin/pip", "install", "typer>=0.9.0", "rich>=13.0.0", "httpx>=0.27.0"
48-
56+
venv = virtualenv_create(libexec, "python3.11")
57+
venv.pip_install "aidocs==${{ steps.pypi.outputs.version }}"
4958
bin.install_symlink libexec/"bin/aidocs"
5059
end
5160
5261
test do
53-
assert_match version.to_s, shell_output("#{bin}/aidocs version")
62+
assert_match "aidocs", shell_output("#{bin}/aidocs version")
5463
end
5564
end
5665
EOF
@@ -61,5 +70,5 @@ jobs:
6170
git config user.name "GitHub Actions"
6271
git config user.email "actions@github.com"
6372
git add Formula/aidocs.rb
64-
git commit -m "Update aidocs to ${{ steps.version.outputs.version }}"
73+
git diff --staged --quiet || git commit -m "Update aidocs to ${{ steps.pypi.outputs.version }}"
6574
git push

0 commit comments

Comments
 (0)