Skip to content

Update Homebrew Tap

Update Homebrew Tap #5

Workflow file for this run

name: Update Homebrew Tap
on:
release:
types: [published]
workflow_run:
workflows: ["Release"]
types: [completed]
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v1.0.0)"
required: true
jobs:
homebrew:
if: github.server_url == 'https://github.com' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
steps:
- name: Get release info
id: release
run: |
TAG="${{ github.event.release.tag_name || github.event.inputs.tag || github.event.workflow_run.head_branch }}"
VERSION="${TAG#v}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Download macOS tarballs and compute checksums
id: checksums
run: |
TAG="${{ steps.release.outputs.tag }}"
BASE="https://github.com/madLinux7/dssh/releases/download/${TAG}"
curl -sL "${BASE}/dssh-darwin-arm64.tar.gz" -o arm64.tar.gz
curl -sL "${BASE}/dssh-darwin-amd64.tar.gz" -o amd64.tar.gz
echo "arm64_sha256=$(sha256sum arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "amd64_sha256=$(sha256sum amd64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: madLinux7/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
run: |
TAG="${{ steps.release.outputs.tag }}"
VERSION="${{ steps.release.outputs.version }}"
ARM64_SHA="${{ steps.checksums.outputs.arm64_sha256 }}"
AMD64_SHA="${{ steps.checksums.outputs.amd64_sha256 }}"
BASE_URL="https://github.com/madLinux7/dssh/releases/download/${TAG}"
cat > Formula/dssh.rb << FORMULA
class Dssh < Formula
desc "Dead Simple SSH - TUI-based SSH connection manager"
homepage "https://github.com/madLinux7/dssh"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "${BASE_URL}/dssh-darwin-arm64.tar.gz"
sha256 "${ARM64_SHA}"
def install
bin.install "dssh-darwin-arm64" => "dssh"
end
elsif Hardware::CPU.intel?
url "${BASE_URL}/dssh-darwin-amd64.tar.gz"
sha256 "${AMD64_SHA}"
def install
bin.install "dssh-darwin-amd64" => "dssh"
end
end
end
test do
assert_match version.to_s, shell_output("#{bin}/dssh --version")
end
end
FORMULA
# Remove leading whitespace from heredoc
sed -i 's/^ //' Formula/dssh.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/dssh.rb
if git diff --cached --quiet; then
echo "Formula already up to date. Nothing to commit."
else
git commit -m "Update dssh to ${{ steps.release.outputs.version }}"
git push
fi