mahiki / homebrew-tap

MIT License
1 stars 0 forks source link

Automate bumping formula and testing build #2

Open mahiki opened 4 months ago

mahiki commented 4 months ago

Goals:

  1. GHA trigger this repository to update the version number
  2. checkout repo, change the formula with new release version number (for url)
  3. run test of built package
  4. merge changes to main. (tag not needed probably?)

RSRC

GHA from source repo, bump formula

triggering GHA action from another repo with API

reusable workflow with on: workflow_call


To make this run smoothly you need to learn a bit about developing homebrew formula and there are a few gotchas in the build/compile/binaries/configurations world of it.

Maybe just build your packages in Julia and deploy those as scripts? Its another path toward solving the same problem. This package's purpose is cleanly deploying packaged python applications to my home macos environment.

update 2024-07-24: I figured out how to deploy installment using poetry. No more need for resource blocks and jinja templates. See below.

update 2024-09-27: this post about GHA trigger from other repo prob has the answer

mahiki commented 4 months ago

Here's something helpful:

https://pypi.org/project/poetry-homebrew-formula/ a package to install with poetry to create the homebrew formula.

https://github.com/tdsmith/homebrew-pypi-poet

mahiki commented 4 months ago

Those docs are great but THIS WORKS - poetry install inside of brew def install:

class Desertislandutils < Formula
  include Language::Python::Virtualenv

  desc "Be here, thy collection of personal convenience utilities"
  homepage "https://github.com/mahiki/homebrew-tap"
  url "https://github.com/mahiki/desertislandutils/releases/download/v0.3.10/desertislandutils-0.3.10.tar.gz"
  sha256 "9c8304fdb02a1fd9d3ffd460cdaf25f1b22a70f2d18ebde700080d328c306216"
  license "MIT"

  depends_on "python@3.11"
  depends_on "poetry"

  def install
    venv = virtualenv_create(libexec, "python3")
    ENV["VIRTUAL_ENV"] = libexec
    ENV.prepend_path "PATH", "#{libexec}/bin"
    puts "install stage libexec path: #{libexec}"
    puts "env VIRTUAL_ENV: #{ENV["VIRTUAL_ENV"]}"
    puts "buildpath: #{buildpath}"
    cd buildpath do
        system "poetry", "install", "--no-root"
    end
    venv.pip_install_and_link buildpath
  end

  test do
    system "#{bin}/wn", "--help"
    system "#{bin}/too", "--help"
  end
end
mahiki commented 4 months ago

Maybe change back to pypi releases via poetry publish. Its easy, and includes the SHA256 unlike github.