feat: install via homebrew (#9)
Add a release job that regenerates Formula/soulseek-rs.rb in michel/homebrew-tap from the archives the binaries matrix uploads, and lead with `brew install michel/tap/soulseek-rs` in the READMEs and on the website.
This commit is contained in:
@@ -185,3 +185,79 @@ jobs:
|
||||
checksum: sha256
|
||||
ref: refs/tags/${{ needs.release.outputs.tag }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Rewrites Formula/soulseek-rs.rb in the tap to point at the archives the
|
||||
# matrix just uploaded. The formula is generated whole rather than patched, so
|
||||
# the workflow is the only place its contents live.
|
||||
homebrew:
|
||||
name: Homebrew tap
|
||||
needs: [release, binaries]
|
||||
if: needs.release.outputs.created == 'true' || inputs.tag != ''
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: michel/homebrew-tap
|
||||
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||
|
||||
- name: Write formula
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ needs.release.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
base="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}"
|
||||
sha() {
|
||||
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \
|
||||
--pattern "soulseek-rs-$TAG-$1.sha256" --output - | cut -d' ' -f1
|
||||
}
|
||||
mkdir -p Formula
|
||||
cat > Formula/soulseek-rs.rb <<EOF
|
||||
# Generated by the soulseek-rs release workflow. Do not edit by hand.
|
||||
class SoulseekRs < Formula
|
||||
desc "Soulseek client in Rust"
|
||||
homepage "https://re-invention.nl/soulseek-rs/"
|
||||
version "${TAG#v}"
|
||||
license "MIT"
|
||||
|
||||
on_macos do
|
||||
on_arm do
|
||||
url "$base/soulseek-rs-$TAG-aarch64-apple-darwin.tar.gz"
|
||||
sha256 "$(sha aarch64-apple-darwin)"
|
||||
end
|
||||
on_intel do
|
||||
url "$base/soulseek-rs-$TAG-x86_64-apple-darwin.tar.gz"
|
||||
sha256 "$(sha x86_64-apple-darwin)"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
on_arm do
|
||||
url "$base/soulseek-rs-$TAG-aarch64-unknown-linux-musl.tar.gz"
|
||||
sha256 "$(sha aarch64-unknown-linux-musl)"
|
||||
end
|
||||
on_intel do
|
||||
url "$base/soulseek-rs-$TAG-x86_64-unknown-linux-musl.tar.gz"
|
||||
sha256 "$(sha x86_64-unknown-linux-musl)"
|
||||
end
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install "soulseek-rs"
|
||||
end
|
||||
|
||||
test do
|
||||
assert_match version.to_s, shell_output("#{bin}/soulseek-rs --version")
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
- name: Commit
|
||||
env:
|
||||
TAG: ${{ needs.release.outputs.tag }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add Formula/soulseek-rs.rb
|
||||
git diff --staged --quiet || git commit -m "soulseek-rs $TAG"
|
||||
git push
|
||||
|
||||
Reference in New Issue
Block a user