@@ -96,11 +96,77 @@ jobs:
9696 needs : release
9797 runs-on : ubuntu-latest
9898 steps :
99- - name : Update Homebrew formula
100- uses : mislav/bump-homebrew-formula-action@v3
99+ - uses : actions/checkout@v4
101100 with :
102- formula-name : memorycli
103- homebrew-tap : memvid/homebrew-tap
104- download-url : https://github.com/memvid/memory-cli/releases/download/${{ github.ref_name }}/memorycli-x86_64-apple-darwin.tar.gz
101+ repository : memvid/homebrew-tap
102+ token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
103+ path : homebrew-tap
104+
105+ - name : Download binaries and calculate SHA256
106+ run : |
107+ VERSION="${{ github.ref_name }}"
108+ BASE_URL="https://github.com/memvid/memory-cli/releases/download/${VERSION}"
109+
110+ # Download and calculate SHA256 for each platform
111+ SHA_X86_64_MACOS=$(curl -sL "${BASE_URL}/memorycli-x86_64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1)
112+ SHA_AARCH64_MACOS=$(curl -sL "${BASE_URL}/memorycli-aarch64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1)
113+ SHA_X86_64_LINUX=$(curl -sL "${BASE_URL}/memorycli-x86_64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1)
114+ SHA_AARCH64_LINUX=$(curl -sL "${BASE_URL}/memorycli-aarch64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1)
115+
116+ echo "SHA_X86_64_MACOS=${SHA_X86_64_MACOS}" >> $GITHUB_ENV
117+ echo "SHA_AARCH64_MACOS=${SHA_AARCH64_MACOS}" >> $GITHUB_ENV
118+ echo "SHA_X86_64_LINUX=${SHA_X86_64_LINUX}" >> $GITHUB_ENV
119+ echo "SHA_AARCH64_LINUX=${SHA_AARCH64_LINUX}" >> $GITHUB_ENV
120+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
121+
122+ - name : Update Homebrew formula
123+ working-directory : homebrew-tap
105124 env :
106- COMMITTER_TOKEN : ${{ secrets.HOMEBREW_TAP_TOKEN }}
125+ VERSION : ${{ github.ref_name }}
126+ BASE_URL : https://github.com/memvid/memory-cli/releases/download/${{ github.ref_name }}
127+ run : |
128+ python3 << 'EOF'
129+ import re
130+ import os
131+
132+ FORMULA_FILE = "Formula/memorycli.rb"
133+ VERSION = os.environ['VERSION'].lstrip('v')
134+ BASE_URL = os.environ['BASE_URL']
135+
136+ with open(FORMULA_FILE, 'r') as f:
137+ content = f.read()
138+
139+ # Update version
140+ content = re.sub(r'version\s+"[^"]+"', f'version "{VERSION}"', content)
141+
142+ # Update all URLs and SHA256s
143+ updates = [
144+ ('x86_64-apple-darwin', os.environ['SHA_X86_64_MACOS']),
145+ ('aarch64-apple-darwin', os.environ['SHA_AARCH64_MACOS']),
146+ ('x86_64-unknown-linux-gnu', os.environ['SHA_X86_64_LINUX']),
147+ ('aarch64-unknown-linux-gnu', os.environ['SHA_AARCH64_LINUX']),
148+ ]
149+
150+ for target, sha256 in updates:
151+ # Update URL
152+ url_pattern = rf'url\s+"[^"]*memorycli-{re.escape(target)}[^"]*"'
153+ new_url = f'url "{BASE_URL}/memorycli-{target}.tar.gz"'
154+ content = re.sub(url_pattern, new_url, content)
155+
156+ # Update SHA256 (find the sha256 line after the URL)
157+ sha256_pattern = rf'(url\s+"[^"]*memorycli-{re.escape(target)}[^"]*"\s*\n\s*)sha256\s+"[^"]+"'
158+ replacement = rf'\1sha256 "{sha256}"'
159+ content = re.sub(sha256_pattern, replacement, content)
160+
161+ with open(FORMULA_FILE, 'w') as f:
162+ f.write(content)
163+ EOF
164+
165+ - name : Commit and push
166+ working-directory : homebrew-tap
167+ run : |
168+ git config user.name "github-actions[bot]"
169+ git config user.email "github-actions[bot]@users.noreply.github.com"
170+ git add Formula/memorycli.rb
171+ git diff --staged --quiet || git commit -m "Update memorycli to ${{ github.ref_name }}"
172+ git push
0 commit comments