diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index bff8f1c..695e997 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -1,4 +1,4 @@ -name: Bump netbird +name: Bump formulae on: schedule: @@ -14,7 +14,12 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Update cask to the latest release + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Update netbird cask to the latest release env: GH_TOKEN: ${{ github.token }} run: | @@ -54,8 +59,41 @@ jobs: sed -i -E "/\/${asset//./\\.}\"/{n;s/[0-9a-f]{64}/${sha[$asset]}/}" "$formula" done git diff - - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git commit -am "chore: bump netbird to $latest" - git push + + - name: Update zshellcheck formula + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + formula=Formula/zshellcheck.rb + repo=afadesigns/zshellcheck + latest=$(gh api repos/$repo/releases/latest --jq .tag_name) + latest=${latest#v} + current=$(sed -nE 's|.*/releases/download/v([^/]+)/.*|\1|p' "$formula" | head -1) + if [ "$latest" = "$current" ]; then + echo "Already at $current" + exit 0 + fi + + # The release publishes checksums.txt with a sha256 for every asset. + if ! checksums=$(curl -fsSL "https://github.com/$repo/releases/download/v$latest/checksums.txt"); then + echo "checksums.txt is not published yet" + exit 0 + fi + sed -i -E "s|/v${current//./\\.}/|/v$latest/|g" "$formula" + for arch in arm64 x86_64; do + asset="zshellcheck_Darwin_${arch}.tar.gz" + sha=$(awk -v a="$asset" '$2 == a { print $1 }' <<<"$checksums") + if [ -z "$sha" ]; then + echo "$asset is not published yet" + git checkout -- "$formula" + exit 0 + fi + sed -i -E "/\/${asset//./\\.}\"/{n;s/[0-9a-f]{64}/$sha/}" "$formula" + done + git diff + git commit -am "chore: bump zshellcheck to $latest" + + - name: Push + run: git push diff --git a/Formula/zshellcheck.rb b/Formula/zshellcheck.rb new file mode 100644 index 0000000..0771334 --- /dev/null +++ b/Formula/zshellcheck.rb @@ -0,0 +1,33 @@ +class Zshellcheck < Formula + desc "Static analysis and auto-fix for Zsh scripts" + homepage "https://github.com/afadesigns/zshellcheck" + license "MIT" + + if Hardware::CPU.arm? + url "https://github.com/afadesigns/zshellcheck/releases/download/v1.8.0/zshellcheck_Darwin_arm64.tar.gz" + sha256 "180879dc1fcd106dda667efa070af3829a38b736c23df1a6e7d9a527787d4038" + else + url "https://github.com/afadesigns/zshellcheck/releases/download/v1.8.0/zshellcheck_Darwin_x86_64.tar.gz" + sha256 "d097a48e93b7a77f6e0ca3c72a4f6aef9c7330963117fe2b1f394f682a651f6e" + end + + livecheck do + url :homepage + strategy :github_latest + end + + depends_on :macos + + def install + bin.install "zshellcheck" + man1.install "man/man1/zshellcheck.1" + bash_completion.install "completions/bash/zshellcheck-completion.bash" => "zshellcheck" + zsh_completion.install "completions/zsh/_zshellcheck" + end + + test do + assert_match version.to_s, shell_output("#{bin}/zshellcheck --version") + (testpath/"t.zsh").write "echo $x\n" + assert_match "ZC1075", shell_output("#{bin}/zshellcheck t.zsh", 1) + end +end diff --git a/README.md b/README.md index 51965a1..9ed5f4d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ My personal Homebrew tap for macOS. | --- | --- | --- | | [`netbird`](https://github.com/netbirdio/netbird) | formula | NetBird CLI and daemon | | [`netbird-ui`](https://github.com/netbirdio/netbird) | cask | NetBird menu bar app | +| [`zshellcheck`](https://github.com/afadesigns/zshellcheck) | formula | Linter for Zsh scripts | ## Install