Skip to content
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

Add support for auto-updating packages #165

Open
kylewlacy opened this issue Jan 20, 2025 · 0 comments
Open

Add support for auto-updating packages #165

kylewlacy opened this issue Jan 20, 2025 · 0 comments

Comments

@kylewlacy
Copy link
Member

In most cases, updating packages in the brioche-packages repo is fairly easy, but it's pretty dry work: look up the package, figure out the latest version number, update the value for project.version, test locally, then open a PR.

By design, this process should be pretty easy to automate. To auto-update a package, all we need to do is figure out how to update project.version properly-- the rest can be handled by a CI pipeline (say, a GitHub Actions workflow running on a schedule, or maybe something based on Rennovate, etc.).

So, here's a design that could work as an MVP for auto-updating packages:

  1. The Brioche project for a package exports an autoUpdate function. When run, it should "return" a new value for the project export. This function could use the GitHub /releases/latest API, or any other means of determining the latest version.
  2. The subcommand brioche auto-update runs this autoUpdate function.
  3. It uses the return value to update the project.bri code-- replacing the old project export with the value from autoUpdate.
  4. It then loads the project and updates any lockfiles.

For (1), the trickiest part of this work is deciding how autoUpdate should "return" the new value. If we literally made it return a JavaScript value, that would be pretty hard to fit with Brioche's current data model: if you tried to bake a process recipe, then the result would be permanently cached!

For an MVP, the easiest option would be for autoUpdate to return a runnable. Here's a simple example based on the ripgrep package:

export const project = {
  name: "ripgrep",
  version: "14.1.0",
};

// ...

export function autoUpdate(): std.Recipe<Directory> {
  return std.bashRunnable`
    latest_version=$(curl 'https://api.github.com/repos/BurntSushi/ripgrep/releases/latest' | jq -r '.tag_name')
    echo "$project_json" | jq '.version = $latest_version' --arg latest_version "$latest_version"
  `
    .env({ project_json: JSON.stringify(project) })
    .dependencies(curl(), jq())
    .toFile()
}

To get the new project value, Brioche would bake the autoUpdate recipe, run the brioche-run executable from the artifact root, then get the new project value from the process's output (stdout in the above example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant