-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Homebrew formula installer support #318
Conversation
@@ -36,6 +36,7 @@ thiserror = "1.0.35" | |||
tracing = { version = "0.1.36", features = ["log"] } | |||
serde = { version = "1.0.144", features = ["derive"] } | |||
cargo_metadata = "0.15.0" | |||
cruet = "0.13.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't feel great about adding another dep, I just wanted to not have to think about the ClassCase conversion.
/// A brief description of the application | ||
pub desc: Option<String>, | ||
/// AMD64 artifact | ||
pub x86_64: Option<ExecutableZipFragment>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that since Homebrew does need to specifically query the x86_64 and ARM binaries, it made sense to promote them to first-class properties of the installer info struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you figured out the general gist, nice!
if target == X64_MACOS { | ||
x86_64 = Some(fragment.clone()); | ||
} | ||
if target == ARM64_MACOS { | ||
arm64 = Some(fragment.clone()); | ||
} | ||
|
||
if do_rosetta_fallback && target == X64_MACOS { | ||
// Copy the info but respecify it to be arm64 macos | ||
let mut arm_fragment = fragment.clone(); | ||
arm_fragment.target_triples = vec![ARM64_MACOS.to_owned()]; | ||
artifacts.push(arm_fragment.clone()); | ||
arm64 = Some(arm_fragment); | ||
} | ||
artifacts.push(fragment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it's intentional that even though we're doing fallback we're not actually assigning the x64 binary to the arm64
var because we want homebrew et al to understand what's going on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow I should read the lines i link more closely, you do assign it to arm64, interesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, more or less I'm mirroring the existing behaviour, even if it would result in an unnecessary if
statement. It'd definitely be possible to just have one url
if the two arches are the same though.
// TODO ensure this is Homebrew-legal | ||
let artifact_name = format!("{release_id}.rb"); | ||
let artifact_path = self.inner.dist_dir.join(&artifact_name); | ||
let hint = format!("brew install {artifact_name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This presumably will need some kind of reference to the tap in the final impl right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's right. For this PR I was focused on getting the formula file rendered out - figured it would make sense to leave the tap stuff to a followup.
b97057b
to
4eb0e1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on the tests!
// TODO ensure this is Homebrew-legal | ||
let artifact_name = format!("{release_id}.rb"); | ||
let artifact_path = self.inner.dist_dir.join(&artifact_name); | ||
let hint = format!("brew install {artifact_name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be deleted until the tap followup?
0d3b366
to
8acd6e9
Compare
ff7ea29
to
abc7aec
Compare
abc7aec
to
c3e7f78
Compare
This starts the work of adding a Homebrew installer. At this point, it generates a usable formula file that installs binaries and doc files, but not other optional features we might want. It also doesn't handle the work of uploading it to a tap yet.
Sample generated formula:
I tested it via
brew install
, and it works just fine; it installs all of the defined binaries, plus the README and license files.refs #308