Skip to content

Point packaging metadata to the real GitHub repo #1

Point packaging metadata to the real GitHub repo

Point packaging metadata to the real GitHub repo #1

name: update-homebrew-tap
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version without leading v"
required: true
default: "1.0.0"
sha256:
description: "SHA256 for mtop source tarball"
required: true
permissions:
contents: read
jobs:
sync-tap:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve Version
id: version
run: |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
echo "value=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
fi
- name: Resolve SHA256
id: sha
run: |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
echo "value=${{ github.event.inputs.sha256 }}" >> "$GITHUB_OUTPUT"
else
VERSION="${{ steps.version.outputs.value }}"
curl -L -o "/tmp/mtop-${VERSION}-source.tar.gz" "https://github.com/lxrzlyr/mtop/releases/download/v${VERSION}/mtop-${VERSION}-source.tar.gz"
echo "value=$(shasum -a 256 /tmp/mtop-${VERSION}-source.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
fi
- name: Start SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.HOMEBREW_TAP_SSH_KEY }}
- name: Trust GitHub Host Key
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Clone Homebrew Tap
run: git clone git@github.com:lxrzlyr/homebrew-mtop.git /tmp/homebrew-mtop
- name: Generate Formula
run: |
./scripts/generate_homebrew_formula.sh \
"${{ steps.version.outputs.value }}" \
"${{ steps.sha.outputs.value }}" \
/tmp/homebrew-mtop/Formula/mtop.rb
- name: Commit And Push
run: |
cd /tmp/homebrew-mtop
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/mtop.rb
if git diff --cached --quiet; then
echo "No tap changes to commit"
exit 0
fi
git commit -m "Update mtop formula to v${{ steps.version.outputs.value }}"
git push origin main