aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-28 17:32:46 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2025-06-28 17:32:46 -0700
commit26d9a5672c6029260266a70e13cf79121071cff4 (patch)
treeb3703f6e4e5698cd9d4a34c67b147fb1ab5875a9 /.github/workflows
parentdbeb4f0361acbeac799f9da940daeba6e26b80c9 (diff)
Add automated Homebrew formula updates on release
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/homebrew-release.yml52
1 files changed, 52 insertions, 0 deletions
diff --git a/.github/workflows/homebrew-release.yml b/.github/workflows/homebrew-release.yml
new file mode 100644
index 0000000..8ea2a38
--- /dev/null
+++ b/.github/workflows/homebrew-release.yml
@@ -0,0 +1,52 @@
+name: Update Homebrew Formulas
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ update-homebrew:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Calculate SHA256 and update formulas
+ env:
+ GITHUB_TOKEN: ${{ secrets.HOMEBREW_UPDATE_TOKEN }}
+ run: |
+ TAG=${GITHUB_REF#refs/tags/}
+ SHA=$(curl -Ls https://github.com/jhalter/mobius/archive/refs/tags/$TAG.tar.gz | shasum -a 256 | cut -d' ' -f1)
+
+ echo "Updating Homebrew formulas for version $TAG with SHA $SHA"
+
+ # Update client formula
+ echo "Updating client formula..."
+ gh api repos/jhalter/homebrew-mobius-hotline-client/contents/mobius-hotline-client.rb \
+ --jq '.content' | base64 -d > client.rb
+
+ CURRENT_CLIENT_SHA=$(gh api repos/jhalter/homebrew-mobius-hotline-client/contents/mobius-hotline-client.rb --jq '.sha')
+
+ sed -i "s/version \".*\"/version \"${TAG#v}\"/" client.rb
+ sed -i "s/sha256 \".*\"/sha256 \"$SHA\"/" client.rb
+
+ gh api repos/jhalter/homebrew-mobius-hotline-client/contents/mobius-hotline-client.rb \
+ -X PUT \
+ -f message="Update to $TAG" \
+ -f content="$(base64 -w 0 client.rb)" \
+ -f sha="$CURRENT_CLIENT_SHA"
+
+ # Update server formula
+ echo "Updating server formula..."
+ gh api repos/jhalter/homebrew-mobius-hotline-server/contents/mobius-hotline-server.rb \
+ --jq '.content' | base64 -d > server.rb
+
+ CURRENT_SERVER_SHA=$(gh api repos/jhalter/homebrew-mobius-hotline-server/contents/mobius-hotline-server.rb --jq '.sha')
+
+ sed -i "s/version \".*\"/version \"${TAG#v}\"/" server.rb
+ sed -i "s/sha256 \".*\"/sha256 \"$SHA\"/" server.rb
+
+ gh api repos/jhalter/homebrew-mobius-hotline-server/contents/mobius-hotline-server.rb \
+ -X PUT \
+ -f message="Update to $TAG" \
+ -f content="$(base64 -w 0 server.rb)" \
+ -f sha="$CURRENT_SERVER_SHA"
+
+ echo "Successfully updated both Homebrew formulas to $TAG" \ No newline at end of file