diff --git a/.github/workflows/update-homebrew-formula.yml b/.github/workflows/update-homebrew-formula.yml new file mode 100644 index 0000000..203cb49 --- /dev/null +++ b/.github/workflows/update-homebrew-formula.yml @@ -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 "action@github.com" + git config --local user.name "GitHub Action" + git commit -am "Update formula to version ${{ github.event.release.tag_name }}" + git push diff --git a/.github/workflows/update_formula.sh b/.github/workflows/update_formula.sh new file mode 100755 index 0000000..2b126aa --- /dev/null +++ b/.github/workflows/update_formula.sh @@ -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 \ No newline at end of file