strapped.sh icon indicating copy to clipboard operation
strapped.sh copied to clipboard

Automatic Homebrew Updates on Release

Open azohra opened this issue 6 years ago • 7 comments

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

  1. checkout the brew tap: https://github.com/azohra/homebrew-tools
  2. download the latest strapped.sh tar.gz artifact
  3. Generate the SHA256 for the downlaoded strapped.tar.gz
  4. Update the SHA256 in https://github.com/azohra/homebrew-tools/blob/master/strapped.rb
  5. Update the version/url in https://github.com/azohra/homebrew-tools/blob/master/strapped.rb
  6. 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

azohra avatar Jul 06 '19 00:07 azohra

@tk8817 are you handling this?

MatthewNielsen27 avatar Jul 06 '19 20:07 MatthewNielsen27

@MatthewNielsen27 - you want it? I have a couple other features I want to build out so happy to pass this off.

azohra avatar Jul 06 '19 20:07 azohra

@tk8817 Sure I'll take this one.

MatthewNielsen27 avatar Jul 06 '19 20:07 MatthewNielsen27

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

MatthewNielsen27 avatar Jul 06 '19 22:07 MatthewNielsen27

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.

azohra avatar Jul 06 '19 23:07 azohra

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

azohra avatar Jul 06 '19 23:07 azohra

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

azohra avatar Jul 06 '19 23:07 azohra