name: Release
on:
push:
tags:
- "v*"
- "[0-9]+.*"
jobs:
build:
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-13
- target: aarch64-apple-darwin
os: macos-14
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../rip-${{ matrix.target }}.tar.gz rip
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rip-${{ matrix.target }}
path: rip-${{ matrix.target }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
rip-x86_64-apple-darwin/rip-x86_64-apple-darwin.tar.gz
rip-aarch64-apple-darwin/rip-aarch64-apple-darwin.tar.gz
update-homebrew:
needs: release
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Get SHA256
id: sha
run: |
echo "arm=$(shasum -a 256 rip-aarch64-apple-darwin/rip-aarch64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "intel=$(shasum -a 256 rip-x86_64-apple-darwin/rip-x86_64-apple-darwin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: cesarferreira/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula and push
env:
ARM_SHA: ${{ steps.sha.outputs.arm }}
INTEL_SHA: ${{ steps.sha.outputs.intel }}
run: |
# Handle both v0.4.0 and 0.4.0 tag formats
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG#v}
cat > homebrew-tap/Formula/rip.rb << EOF
class Rip < Formula
desc "Fuzzy find and kill processes from your terminal"
homepage "https://github.com/cesarferreira/rip"
version "${VERSION}"
license "MIT"
on_macos do
on_arm do
url "https://github.com/cesarferreira/rip/releases/download/${TAG}/rip-aarch64-apple-darwin.tar.gz"
sha256 "${ARM_SHA}"
end
on_intel do
url "https://github.com/cesarferreira/rip/releases/download/${TAG}/rip-x86_64-apple-darwin.tar.gz"
sha256 "${INTEL_SHA}"
end
end
def install
bin.install "rip"
end
test do
system "#{bin}/rip", "--help"
end
end
EOF
# Remove leading spaces from heredoc
sed -i'' -e 's/^ //' homebrew-tap/Formula/rip.rb
cd homebrew-tap
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add Formula/rip.rb
git commit -m "Update rip to ${VERSION}"
git push