How do I create homebrew bottle for old version on a new macOS version?

I know this is an old issue, but for new comers, I've published an automated build workflow to create and publish bottles for your taps with Azure Pipelines & Bintray.

You can find more information here:

https://github.com/ladislas/homebrew-greetings

And a real life example is the osx-cross/avr tap that I maintain that now offers bottles for all the formulae including all the versions of avr-gcc from 9.1.0 to 4.x.x.

https://github.com/osx-cross/homebrew-avr/

EDIT (2021/03/15) - Homebrew has greatly improved support for custom taps' bottles see:

Homebrew tap with bottles uploaded to GitHub Releases

osx-cross/avr now makes full use of this with Github Actions, you can look into .github/workflows for details.


How do I create homebrew bottle for old version on a new macOS version?

I've successfully build a zsh 5.1.1 bottle on macOS Sierra. Here is how:

First you need to download all commits from the homebrew-core repository because by defaut it's a shallow repository (not all commits are present).

cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git fetch --unshallow

You then have to select the last commit of zsh 5.1.1 with

brew log zsh

Here, it's the commit 1a4461ad2a0f1bc7074d9817d, checkout the zsh formula for this commit

git checkout 1a4461ad2a0f1bc7074d9817d -- Formula/zsh.rb

Install zsh with --build-bottle

brew install --build-bottle zsh

and build the bottle

brew bottle zsh

You then obtain the bottle file zsh-5.1.1.sierra.bottle.1.tar.gz

Don't forget to restore the original state of zsh.rb with

git checkout -- Formula/zsh.rb

For installing the bottle, just copy it in /usr/local/Cellar, extract it with

tar xzvf zsh-5.1.1.sierra.bottle.1.tar.gz 

and link it with

brew link zsh

== Edit to answer the OP comment ==

Official homebrew bottles are stored in bintray.com. Bintray is a distribution platform with REST api. When you launch brew install, it first check if there is a bottle there. The zsh 5.1.1 bottles are stored in : https://bintray.com/homebrew/bottles/zsh/5.1.1#files. As you can see there is a version for yosemite, mavericks and el capitan, but no version for sierra. You could ask on github to put the zsh-5.1.1 sierra bottle there.