Tinfoil.Plan (tinfoil v0.2.22)

Copy Markdown View Source

Build a structured plan describing what tinfoil would build and release from the current config.

The plan is the shared data structure between mix tinfoil.plan (human output), the GitHub Actions build matrix (JSON output), and future mix tinfoil.build / mix tinfoil.publish tasks.

This module is deliberately pure — no filesystem, no network, no shelling out — so it is trivial to test and safe to call from any context. The companion mix tinfoil.plan task layers in side effects on top: pretty-printing for humans, and NIF cross-compile warnings via Tinfoil.NifCheck.

Summary

Functions

Build a plan map from a resolved %Tinfoil.Config{}.

Return the list of build job matrix entries.

Return the GitHub Actions matrix fragment — an object with an include array, one entry per target.

Types

build_entry()

@type build_entry() :: %{id: String.t(), targets: String.t(), runner: String.t()}

t()

@type t() :: %{
  app: atom(),
  version: String.t(),
  archive_format: atom(),
  checksums: atom(),
  trigger: atom(),
  ci: map(),
  targets: [target_plan()],
  single_runner_per_os: boolean(),
  attestations: boolean(),
  github: map(),
  homebrew: map(),
  scoop: map(),
  installer: map()
}

target_plan()

@type target_plan() :: %{
  target: Tinfoil.Target.target(),
  burrito_name: atom(),
  runner: String.t(),
  triple: String.t(),
  burrito_os: atom(),
  burrito_cpu: atom(),
  os_family: atom(),
  archive: String.t()
}

Functions

build(config)

@spec build(Tinfoil.Config.t()) :: t()

Build a plan map from a resolved %Tinfoil.Config{}.

The :targets list preserves the order the user configured.

build_entries(map)

@spec build_entries(t()) :: [build_entry()]

Return the list of build job matrix entries.

In the default (single_runner_per_os: false) mode every tinfoil target is its own entry, so the CI matrix is one job per target.

When :single_runner_per_os is true, targets that share both a runner and an OS family are collapsed into a single entry. The :targets field is a comma-separated list of tinfoil target names that the generated workflow loops over with a shell for.

matrix(map)

@spec matrix(t()) :: %{include: [target_plan()]}

Return the GitHub Actions matrix fragment — an object with an include array, one entry per target.

Suitable for feeding into strategy.matrix via fromJson():

- id: plan
  run: echo "matrix=$(mix tinfoil.plan --format matrix)" >> $GITHUB_OUTPUT

build:
  needs: plan
  strategy:
    matrix: ${{ fromJson(needs.plan.outputs.matrix) }}