1 Commits

Author SHA1 Message Date
a69ee802a6 feat(homebrew): add standalone homebrew release workflow 2026-03-19 00:39:37 +02:00

89
.github/workflows/homebrew-release.yml vendored Normal file
View File

@@ -0,0 +1,89 @@
# Reusable Homebrew Release Workflow
#
# Dispatches a homebrew formula update to a tap repo.
# Does not include any build steps — suitable for shell-only packages.
#
# Call from other repos:
# jobs:
# homebrew:
# uses: chenasraf/workflows/.github/workflows/homebrew-release.yml@master
# with:
# homebrew-tap-repo: owner/homebrew-tap
# tag: ${{ needs.release.outputs.tag_name }}
# secrets:
# REPO_DISPATCH_PAT: ${{ secrets.REPO_DISPATCH_PAT }}
name: Homebrew Release
on:
workflow_call:
inputs:
homebrew-tap-repo:
description: 'Homebrew tap repo to dispatch to (e.g., owner/homebrew-tap)'
required: true
type: string
tag:
description: 'Release tag to dispatch (e.g., v1.0.0). If empty, uses the latest release tag.'
required: false
type: string
default: ''
secrets:
REPO_DISPATCH_PAT:
description: 'PAT for dispatching to homebrew tap repo'
required: true
permissions:
contents: read
jobs:
release-homebrew:
name: Trigger Homebrew Formula Update
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get release info
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${{ inputs.tag }}"
if [[ -z "$tag" ]]; then
tag=$(gh release view --json tagName -q .tagName)
echo "Using latest release tag: $tag"
else
echo "Using provided tag: $tag"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
body=$(gh release view "$tag" --json body -q .body)
echo "body<<EOF" >> "$GITHUB_OUTPUT"
echo "$body" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Send dispatch to homebrew-tap
env:
GH_TOKEN: ${{ secrets.REPO_DISPATCH_PAT }}
run: |
tag="${{ steps.release.outputs.tag }}"
repo="${{ github.event.repository.name }}"
body=$(cat <<'BODY_EOF'
${{ steps.release.outputs.body }}
BODY_EOF
)
data=$(jq -n \
--arg tag "$tag" \
--arg repo "$repo" \
--arg body "$body" \
'{event_type: "trigger-from-release", client_payload: {tag: $tag, repo: $repo, body: $body}}')
echo "Dispatching tag $tag from $repo"
echo "Data: $data"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
"https://api.github.com/repos/${{ inputs.homebrew-tap-repo }}/dispatches" \
-d "$data"
echo "Dispatched tag $tag from $repo"
echo "Created job on https://github.com/${{ inputs.homebrew-tap-repo }}/actions"