Automatic Homebrew Updates on Release
Is your feature request related to a problem? Please describe. It is very annoying to generate new releases on our homebrew tap right now. We need to
- checkout the brew tap: https://github.com/azohra/homebrew-tools
- download the latest strapped.sh tar.gz artifact
- Generate the SHA256 for the downlaoded strapped.tar.gz
- Update the SHA256 in https://github.com/azohra/homebrew-tools/blob/master/strapped.rb
- Update the version/url in https://github.com/azohra/homebrew-tools/blob/master/strapped.rb
- Commit the changes and push a PR to master for the tap.
Describe the solution you'd like Create a Make task which will do all of this for us, ideally using the github API where we make a remote PR + auto merge.
Describe alternatives you've considered Being better in general
Additional context 2+2 = 4 C is the 3rd letter of the alphabet
@tk8817 are you handling this?
@MatthewNielsen27 - you want it? I have a couple other features I want to build out so happy to pass this off.
@tk8817 Sure I'll take this one.
Hey @tk8817, I got most of it done. How would you recommend we handle the git stuff?
diff: https://github.com/azohra/strapped.sh/compare/feature/automate-homebrew-releases
I think it can be done entirely remote via the Github API.
#Get SHA of Master
MASTER_SHA=`curl https://api.github.com/repos/azohra/homebrew-tools/git/refs/heads/master | jq .object.sha`
#POST to make branch
https://api.github.com/repos/azohrahomebrew-tools/git/refs
{
"ref": "refs/heads/revision-strapped-${VERSION}",
"sha": "${MASTER_SHA}"
}
#GET the contents of strapped.rb file
https://developer.github.com/v3/repos/contents/#get-contents
#POST to update strapped.rb file
https://developer.github.com/v3/repos/contents/#create-or-update-a-file
#POST to create a pull request
https://developer.github.com/v3/pulls/#create-a-pull-request
#PUT to merge a pull request
https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
I gotta run for dinner, got lazier as I was writing that. It should work though.
One note, I see you are using the $VERSION in the repo to get the latest release, I would advise instead pulling the latest release from GitHub itself.
curl -s https://api.github.com/repos/azohra/strapped.sh/releases/latest
from the response of that you can get the actual version and the url to the artifact
I am also realizing that we should put this code into the home brew-Tools repo instead of strapped, and we should send an event / webhook from strapped to home brew-tools on every release