Skip to content

Update Maints-Triage Formula #1

Update Maints-Triage Formula

Update Maints-Triage Formula #1

name: Update Maints-Triage Formula
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v0.1.0)'
required: true
type: string
permissions:
contents: write
pull-requests: write
jobs:
update-formula:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Download and calculate SHA256
id: calculate-sha
run: |
VERSION="${{ github.event.inputs.version }}"
# Ensure version starts with 'v' for the tag
if [[ ! "$VERSION" =~ ^v ]]; then
VERSION="v${VERSION}"
fi
URL="https://github.com/codcod/maints-triage/releases/download/${VERSION}/triage-${VERSION}-darwin-universal.tar.gz"
echo "Downloading ${URL}"
# Download with error checking
if ! curl -L "${URL}" -o triage.tar.gz -f; then
echo "❌ Failed to download release ${VERSION}"
echo "❌ URL: ${URL}"
echo "❌ This release may not exist. Please check:"
echo " https://github.com/codcod/maints-triage/releases"
exit 1
fi
# Check file size (should be more than 100 bytes for a real binary)
FILE_SIZE=$(stat -c%s triage.tar.gz)
if [ "$FILE_SIZE" -lt 100 ]; then
echo "❌ Downloaded file is too small (${FILE_SIZE} bytes)"
echo "❌ This suggests the release doesn't exist or the URL is incorrect"
echo "❌ URL: ${URL}"
exit 1
fi
SHA256=$(shasum -a 256 triage.tar.gz | cut -d' ' -f1)
echo "✅ Successfully downloaded ${FILE_SIZE} bytes"
echo "SHA256: ${SHA256}"
echo "url=${URL}" >> $GITHUB_OUTPUT
echo "sha256=${SHA256}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Update maints-triage.rb formula
run: |
URL="${{ steps.calculate-sha.outputs.url }}"
SHA256="${{ steps.calculate-sha.outputs.sha256 }}"
# Update the URL line
sed -i "s|url \".*\"|url \"${URL}\"|" maints-triage.rb
# Update the SHA256 line
sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" maints-triage.rb
echo "Updated maints-triage.rb with:"
echo " URL: ${URL}"
echo " SHA256: ${SHA256}"
- name: Verify formula syntax
run: |
# Simple Ruby syntax check
ruby -c maints-triage.rb
echo "Formula syntax is valid"
- name: Create branch and push changes
run: |
# Configure git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Create branch name
BRANCH_NAME="update-maints-triage-${{ steps.calculate-sha.outputs.version }}"
# Delete branch if it exists locally
git branch -D "$BRANCH_NAME" 2>/dev/null || true
# Delete branch if it exists remotely
git push origin --delete "$BRANCH_NAME" 2>/dev/null || true
# Create and switch to new branch
git checkout -b "$BRANCH_NAME"
# Add and commit changes
git add maints-triage.rb
git commit -m "Update maints-triage formula to ${{ steps.calculate-sha.outputs.version }}"
# Push the branch (force push to handle any conflicts)
git push --force origin "$BRANCH_NAME"
echo "✅ Branch pushed successfully!"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
run: |
BRANCH_NAME="update-maints-triage-${{ steps.calculate-sha.outputs.version }}"
gh pr create \
--title "Update maints-triage formula to ${{ steps.calculate-sha.outputs.version }}" \
--body "This PR updates the maints-triage formula to version \`${{ steps.calculate-sha.outputs.version }}\`.
## Changes
- **Updated URL to:** \`${{ steps.calculate-sha.outputs.url }}\`
- **Updated SHA256 to:** \`${{ steps.calculate-sha.outputs.sha256 }}\`
The formula has been validated with Ruby syntax check.
**Auto-generated by GitHub Actions** 🤖" \
--head "$BRANCH_NAME" \
--base main
echo "✅ Pull request created successfully!"
echo "🔗 View at: https://github.com/codcod/homebrew-taps/pulls"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}