v1.1.0 #17
Workflow file for this run
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: | |
release: | |
types: [published] | |
branches: [main] | |
jobs: | |
update-formula: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout software repo | |
uses: actions/checkout@v4 | |
with: | |
path: 'software' | |
- name: Checkout Homebrew tap | |
uses: actions/checkout@v4 | |
with: | |
repository: 'therealpaulgg/homebrew-ssh-sync' | |
token: ${{ secrets.ACCESS_TOKEN_CLASSIC }} | |
path: 'homebrew-tap' | |
- name: Update Homebrew formula | |
run: | | |
cd homebrew-tap | |
GITHUB_REPO="therealpaulgg/ssh-sync" | |
FORMULA_PATH="Formula/ssh-sync.rb" | |
TAP_REPO="therealpaulgg/homebrew-ssh-sync" | |
# 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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN_CLASSIC }} | |
- name: Commit and push updates to the tap | |
run: | | |
cd homebrew-tap | |
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 }}" || echo "No changes to commit" | |
git push |