Skip to content

Commit c2ee697

Browse files
committed
Enhance Homebrew formula update process in GitHub Actions workflow
- Updated the workflow to include retry logic for downloading release archives with improved error handling. - Simplified the formula creation process and ensured SHA256 checksum calculation for the downloaded archive. - Cleaned up temporary files after the formula creation to maintain a tidy workspace.
1 parent b428d59 commit c2ee697

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

.github/workflows/release.yml

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -193,56 +193,58 @@ jobs:
193193
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
194194
path: tap
195195

196-
- name: Download release info and update formula
196+
- name: Update Homebrew formula
197197
run: |
198198
VERSION=${GITHUB_REF#refs/tags/v}
199+
echo "Processing version: ${VERSION}"
199200
200-
# Download archives to calculate SHA256
201201
cd tap
202202
203-
# Download macOS AMD64
204-
wget -q "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/mcpproxy-v${VERSION}-darwin-amd64.tar.gz"
205-
AMD64_SHA=$(sha256sum "mcpproxy-v${VERSION}-darwin-amd64.tar.gz" | cut -d' ' -f1)
203+
# Add debugging and retry logic
204+
ARCHIVE_URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz"
205+
echo "Downloading from: ${ARCHIVE_URL}"
206+
207+
# Wait a bit for GitHub to generate the archive
208+
sleep 10
209+
210+
# Try downloading with retries
211+
for i in {1..5}; do
212+
echo "Download attempt ${i}/5..."
213+
if wget -q "${ARCHIVE_URL}" -O "v${VERSION}.tar.gz"; then
214+
echo "Download successful"
215+
break
216+
else
217+
echo "Download failed, retrying in 10 seconds..."
218+
sleep 10
219+
fi
220+
221+
if [ $i -eq 5 ]; then
222+
echo "All download attempts failed"
223+
echo "Checking if file exists at URL..."
224+
curl -I "${ARCHIVE_URL}" || true
225+
exit 1
226+
fi
227+
done
206228
207-
# Download macOS ARM64
208-
wget -q "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/mcpproxy-v${VERSION}-darwin-arm64.tar.gz"
209-
ARM64_SHA=$(sha256sum "mcpproxy-v${VERSION}-darwin-arm64.tar.gz" | cut -d' ' -f1)
229+
# Verify file was downloaded
230+
if [ ! -f "v${VERSION}.tar.gz" ]; then
231+
echo "Archive file not found after download"
232+
ls -la
233+
exit 1
234+
fi
210235
211-
# Update formula
212-
cat > Formula/mcpproxy.rb << EOF
213-
class Mcpproxy < Formula
214-
desc "Smart MCP Proxy - Intelligent tool discovery and proxying for Model Context Protocol servers"
215-
homepage "https://github.com/smart-mcp-proxy/mcpproxy-go"
216-
version "${VERSION}"
217-
218-
on_macos do
219-
if Hardware::CPU.arm?
220-
url "https://github.com/smart-mcp-proxy/mcpproxy-go/releases/download/v#{version}/mcpproxy-v#{version}-darwin-arm64.tar.gz"
221-
sha256 "${ARM64_SHA}"
222-
else
223-
url "https://github.com/smart-mcp-proxy/mcpproxy-go/releases/download/v#{version}/mcpproxy-v#{version}-darwin-amd64.tar.gz"
224-
sha256 "${AMD64_SHA}"
225-
end
226-
end
227-
228-
def install
229-
bin.install "mcpproxy"
230-
end
231-
232-
test do
233-
system "#{bin}/mcpproxy", "--version"
234-
end
235-
end
236-
EOF
237-
238-
# Clean up downloaded files
239-
rm -f *.tar.gz
236+
# Calculate SHA256
237+
SOURCE_SHA=$(sha256sum "v${VERSION}.tar.gz" | cut -d' ' -f1)
238+
echo "Calculated SHA256: ${SOURCE_SHA}"
240239
241-
- name: Commit and push changes
242-
run: |
243-
cd tap
244-
git config user.name "github-actions[bot]"
245-
git config user.email "github-actions[bot]@users.noreply.github.com"
246-
git add Formula/mcpproxy.rb
247-
git commit -m "Update mcpproxy to ${GITHUB_REF#refs/tags/v}"
248-
git push
240+
# Create formula directory
241+
mkdir -p Formula
242+
243+
# Create formula file
244+
printf 'class Mcpproxy < Formula\n desc "Smart MCP Proxy - Intelligent tool discovery and proxying for Model Context Protocol servers"\n homepage "https://github.com/smart-mcp-proxy/mcpproxy-go"\n url "https://github.com/smart-mcp-proxy/mcpproxy-go/archive/refs/tags/v%s.tar.gz"\n sha256 "%s"\n license "MIT"\n head "https://github.com/smart-mcp-proxy/mcpproxy-go.git"\n\n depends_on "go" => :build\n\n def install\n system "go", "build", "-ldflags", "-s -w", "-o", "mcpproxy", "./cmd/mcpproxy"\n bin.install "mcpproxy"\n end\n\n test do\n assert_match version.to_s, shell_output("#{bin}/mcpproxy --version")\n end\nend\n' "${VERSION}" "${SOURCE_SHA}" > Formula/mcpproxy.rb
245+
246+
echo "Formula created successfully"
247+
cat Formula/mcpproxy.rb
248+
249+
# Clean up
250+
rm -f *.tar.gz

0 commit comments

Comments
 (0)