Update Homebrew Formula #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Homebrew Formula | |
on: | |
workflow_run: | |
workflows: ["Release"] | |
types: | |
- completed | |
jobs: | |
update-formula: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Get the latest tag | |
id: get-latest-tag | |
run: echo "LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)" >> $GITHUB_ENV | |
- name: Update Homebrew Formula | |
run: | | |
LATEST_TAG=${{ steps.get-latest-tag.outputs.LATEST_TAG }} | |
SHA256=$(curl -sL https://github.com/JianZcar/FuzPad/releases/download/${{ env.LATEST_TAG }}/fuzpad-${{ env.LATEST_TAG }}.tar.gz | sha256sum | awk '{print $1}') | |
cat > fuzpad.rb <<EOF | |
class Fuzpad < Formula | |
desc "Minimalistic note management solution. Powered by fzf" | |
homepage "https://github.com/JianZcar/FuzPad" | |
url "https://github.com/JianZcar/FuzPad/releases/download/${{ env.LATEST_TAG }}/fuzpad-${{ env.LATEST_TAG }}.tar.gz" | |
sha256 "$SHA256" | |
license "GPL-3.0-or-later" | |
livecheck do | |
url :stable | |
strategy :github_latest | |
end | |
depends_on "bat" | |
depends_on "fzf" | |
def install | |
bin.install "fuzpad" | |
end | |
test do | |
assert_equal "1", shell_output("#{bin}/fuzpad --test 2>&1 | grep -q \"1\" && echo 1 || echo 0").strip | |
end | |
end | |
EOF | |
- name: Checkout homebrew-packages repository | |
uses: actions/checkout@v2 | |
with: | |
repository: JianZcar/homebrew-packages | |
token: ${{ secrets.TOKEN }} | |
path: homebrew-packages | |
- name: Move updated formula to homebrew-packages | |
run: | | |
mv fuzpad.rb homebrew-packages/Formula/fuzpad.rb | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
run: | | |
cd homebrew-packages | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add Formula/fuzpad.rb | |
git commit -m "(Fuzpad Update) Update Homebrew formula for FuzPad version ${{ env.LATEST_TAG }}" | |
git push https://x-access-token:${GITHUB_TOKEN}@github.com/JianZcar/homebrew-packages.git HEAD:main |