Skip to content

Commit

Permalink
add homebrew github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
therealpaulgg committed Mar 27, 2024
1 parent 3741bb8 commit 1a6406d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/update-homebrew-formula.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update Homebrew Formula

on:
release:
types: [published]

jobs:
update-formula:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
repository: 'therealpaulgg/homebrew-ssh-sync'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Update Homebrew formula
run: |
# Example commands to update formula
# You'll need a script that updates your formula file with the new version and sha256
# This might involve downloading the release tarball, calculating its sha256, and updating the formula file accordingly
sh update_formula.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit and push
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "Update formula to version ${{ github.event.release.tag_name }}"
git push
20 changes: 20 additions & 0 deletions .github/workflows/update_formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Replace these variables with your actual data
GITHUB_REPO="therealpaulgg/ssh-sync" # Your GitHub username and repository name
FORMULA_PATH="Formula/ssh-sync.rb" # Path to your formula in the tap
TAP_REPO="therealpaulgg/homebrew-ssh-sync" # Your tap repository

# Fetch the latest release data from GitHub
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest")

# Extract the version and tarball URL from the release data
VERSION=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
TARBALL_URL=$(echo "$LATEST_RELEASE" | jq -r '.tarball_url')

# Download the tarball and calculate its SHA256
SHA256=$(curl -Ls $TARBALL_URL | shasum -a 256 | awk '{print $1}')

# Update the formula with the new version and sha256
sed -i "" "s|url \".*\"|url \"$TARBALL_URL\"|g" $FORMULA_PATH
sed -i "" "s|sha256 \".*\"|sha256 \"$SHA256\"|g" $FORMULA_PATH

0 comments on commit 1a6406d

Please sign in to comment.