Closed lukepistrol closed 7 months ago
In simple terms this would work if added to the homebrew/homebrew-cask repo:
cask 'timemachinestatus' do
version '0.0.4'
sha256 'dc94978d507aa1a2680bae3483be1511234dd0de7b72fc8bbb96775694c66403'
url 'https://github.com/lukepistrol/TimeMachineStatus/releases/download/0.0.4/TimeMachineStatus.dmg'
name 'TimeMachineStatus'
desc 'TimeMachineStatus is a little menu bar application for macOS which aims to show more useful information than the system default.'
homepage 'https://github.com/lukepistrol/TimeMachineStatus'
app 'TimeMachineStatus.app'
end
However there might be a better way to handle it (I didn't want to PR since it would require you to have a PAT and this is your project 😅) but testing would be required and maybe some checks to when the rb
file is pushed and when it is not.
Create a local timemachinestatus.rb
file with the above data
Create a new action.yml
file:
name: Update Homebrew Cask
on:
release:
types: [published]
jobs:
update-cask:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0' # or whatever version you prefer
- name: Update Cask
run: |
VERSION=${GITHUB_REF#refs/tags/}
URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}/TimeMachineStatus.dmg"
SHA256=$(curl -Ls $URL | shasum -a 256 | cut -d ' ' -f 1)
# Replace version and sha256 in your cask file
sed -i "s/version '.*'/version '${VERSION}'/" Casks/timemachinestatus.rb
sed -i "s/sha256 '.*'/sha256 '${SHA256}'/" Casks/timemachinestatus.rb
git config --global user.name 'Your Name'
git config --global user.email 'your-email@example.com'
git add Casks/timemachinestatus.rb
git commit -m "Update TimeMachineStatus to ${VERSION}"
git push
- name: Fork Homebrew Cask Repository
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const github = require('@actions/github');
await github.repos.createFork({
owner: 'Homebrew',
repo: 'homebrew-cask',
});
- name: Clone Forked Homebrew Cask Repository
run: |
git clone https://github.com/${{ github.actor }}/homebrew-cask.git
cd homebrew-cask
git remote add upstream https://github.com/Homebrew/homebrew-cask.git
git fetch upstream
git checkout -b update-timemachinestatus-${VERSION} upstream/master
- name: Copy Updated Cask to Fork
run: |
cp ../Casks/timemachinestatus.rb Casks/timemachinestatus.rb
cd homebrew-cask
git add Casks/timemachinestatus.rb
git commit -m "Update TimeMachineStatus to ${VERSION}"
git push --set-upstream origin update-timemachinestatus-${VERSION}
- name: Create Pull Request to Homebrew Cask
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GH_PAT }}
commit-message: Update TimeMachineStatus cask
title: 'Update TimeMachineStatus to ${VERSION}'
body: 'Update TimeMachineStatus cask to the latest release.'
branch: update-timemachinestatus-${VERSION}
base: 'master'
repo: Homebrew/homebrew-cask
This is all kind of theoretical but definitely along the lines of automating it into when you make a release it would update the cask.
How It Works:
Mind you it would be something to investigate whether fully automating it would be in the guidelines or if manually updating the homebrew repo is safer
Thanks for the write up!
I just created a cask locally. However a repository must be "notable" enough to be accepted.
Blocking this for now.
It has 76 stars now, is it just 1 criteria that needs to be met for it to be eligible?
@spitfire I've already submitted a PR.
Now that the first version is released, it'd be nice to add it to Homebrew, so anyone can install it a bit easier.