Skip to content

v5.0.0

Choose a tag to compare

@github-actions github-actions released this 11 Sep 23:54
· 3 commits to main since this release

v5.0.0

v5.0.0 makes deployment environments a project declaration instead of a Bear
constant, and separates deciding what would deploy from executing it: bear plan now runs no commands at all, and bear apply now builds every artifact it
deploys immediately before deploying it.

This release has three breaking changes, independent of each other:

  1. bear.config.yml gains a required environments list, and the hardcoded
    dev/int/prd set is gone.
  2. bear plan no longer runs language build steps for anything it plans, and
    bear apply now runs them immediately before a deploying artifact's target
    deploy steps, uniformly for normal and pinned deployments.
  3. bear check is renamed to bear doctor, with no alias.

This release also ships
bear validate, the merge-request command previously
prepared as v4.2.0, which was never tagged and is folded into this line.

It also makes bear list and bear list --tree load and
validate the artifact graph before printing anything, using the exact same checks
and error wording bear plan and bear validate already used — duplicate names,
unknown targets, undeclared allowlist entries, unresolved dependencies, and cycles.
This is not a breaking change: a structurally valid project sees identical
list/tree output as before. Only a previously broken project that silently
produced partial or misleading list/tree output now fails fast with a clear
error instead. bear doctor is unaffected and remains the dedicated tool for a
full diagnostic report of everything wrong at once, including non-fatal warnings.

The Environments Change

name: my-platform
environments: [dev, preprd, prd]

Every environment rule is now checked against that list:

Upgrading with environments: [dev, int, prd] reproduces v4 behaviour exactly. See
the v5 upgrade guide.

Why

dev, int, prd was a guess about how organisations run software, compiled into
a build tool. It is a common layout. It is not the only one, and Bear had no
business insisting on it.

Real projects use preprd and prd. Some have a single environment and no staging
tier at all. Some have four, or name the middle one uat, qa, or staging.
Under v4 every one of those had to bend: reuse int to mean preprd and hope
readers translated it, or spell the intent in a variable Bear ignored. The word
appeared in the lock file, in $ENVIRONMENT, and in the CI command, so the mismatch
was visible in exactly the places people read when a deployment went wrong.

Making the list configuration also removes a class of silent error. A project that
declares [preprd, prd] gets unknown environment "int" instead of a plan for an
environment it does not have, and an artifact that still allows dev fails
bear doctor rather than quietly never deploying.

Declaration order deliberately carries no meaning beyond ordering. Bear is not a
pipeline engine, and a list in a YAML file is not a promotion policy: nothing here
stops bear plan prd on source that never reached int. Order determines what
messages and listings look like, and that is all.

Naming Rules

A name must match [a-z][a-z0-9-]* and be 1 to 32 characters. Duplicates are
rejected. The constraint exists because the value becomes a bear.lock.yml key, the
injected ENVIRONMENT value, and a positional CLI argument, so it stays short,
lowercase, and free of anything that would need quoting in a shell or in YAML.

The New Errors

Loading the config, in bear doctor, bear list, bear plan, and bear validate:

bear.config.yml: environments must list at least one deployment environment, for example [dev, int, prd]
bear.config.yml: environments: invalid environment name "Prd": use 1 to 32 characters matching [a-z][a-z0-9-]*
bear.config.yml: environments: duplicate environment "dev"

Selecting an environment, from bear plan <environment> and
bear validate --environment:

unknown environment "production": bear.config.yml declares dev, int, prd

A malformed value is rejected first, by syntax, before the declaration is
consulted — bear plan PRD reports invalid environment name "PRD".

An artifact allowlist entry that the project does not declare, from bear plan,
bear validate, and bear doctor:

artifact "api" allows undeclared environment "preprd"; bear.config.yml declares dev, int, prd

bear doctor applies that rule per artifact, so one run lists every offender instead
of stopping at the first, and states the declared set above the verdict:

  Environments: dev, int, prd

  All checks passed!

bear init validates --environments before writing anything, because an
unloadable config is worse than no config:

--environments must list at least one deployment environment, for example dev,int,prd
--environments: invalid environment name "PRD": use 1 to 32 characters matching [a-z][a-z0-9-]*
--environments: duplicate environment "prd"

bear init --environments

bear init                              # dev,int,prd
bear init --environments preprd,prd    # comma-separated
bear init --environments dev --environments uat --environments prd  # or repeated

The default is dev,int,prd — a starting point, not a rule. Declaration order is
preserved in the generated file, and the closing "Next steps" repeats the list it
wrote.

bear apply's Environment Handling Is Unchanged, Deliberately

Apply does not read the current configuration, and this release did not make it
start. The saved plan is the approved snapshot, so no change to the project's
declared environments can make apply reject an approved plan on policy grounds: a
plan for preprd still applies to preprd after the project stops declaring it,
and its lock history is written under preprd. Apply runs on a config that would
not even load, so upgrading the binary strands no in-flight approved plan on the
environment-declaration front
.

Apply keeps exactly the checks it already had — the saved environment name's syntax,
each artifact's saved allowlist, and each saved ENVIRONMENT variable — because
those are evidence of what was approved, not instructions to reload policy. The only
visible difference is wording: its messages no longer say (dev, int, or prd).

Editing bear.config.yml is a different thing entirely. It is ordinary tracked
source, so an edit in the approved checkout invalidates the plan through the
source fingerprint, exactly as editing any
other file would. Apply an in-flight plan before adding environments:, or replan
afterwards.

This section is about the environments change only. Apply's execution model did
change in this release — see the next section — and that change means a plan
approved by a pre-upgrade binary should not be applied with this one; regenerate
it instead.

The Plan/Apply Execution Model Change

Before this release, bear plan ran every changed artifact's language build
steps as part of planning, and a --pin plan additionally validated the pinned
commit in a private worktree. bear apply only ran target deploy steps for a
normal deployment; for a pinned deployment, it first replayed the saved
validation/setup steps in a fresh worktree, because the pinned worktree from
plan time no longer existed by the time apply ran.

bear plan now runs zero commands, for a normal plan or a --pin plan. It
computes what would be deployed or skipped by comparing against bear.lock.yml
per environment — the same dependency-aware change detection as before,
unchanged — and writes .bear/plan.yml. It still requires clean Git source
before planning any deployment, resolves and snapshots the exact source commit
and fingerprint (including for --pin, via an isolated worktree), enforces
environment/allowlist policy, and rejects unknown artifact names. It is now
near-instant.

bear apply is now the only place anything ever runs. For every deploying
artifact it runs, in one continuous progress task: the language's steps
(whatever languages.<lang>.steps contains) first, then the target's deploy
steps, uniformly for normal and pinned deployments. The old special case —
where only a pinned apply replayed validation in a fresh worktree — is gone;
every apply now always runs language-then-target steps for every artifact it
deploys, through a single code path.

Why

bear plan is now genuinely just a plan: fast, side-effect-free, safe to run as
often as you like, and it never risks running untrusted build/deploy commands
just to show a diff. bear apply is the only command that executes anything,
and it now does the complete job for a deploying artifact — build and deploy —
in one place, instead of splitting "build happens during plan, assuming the
same checkout persists to apply time" from "deploy happens during apply."

This also removes an entire class of prior complexity: a pinned deployment used
to need a special "replay validation in a fresh worktree" step specifically
because plan's in-place build didn't carry over to a pinned apply's isolated
worktree. Now every apply, pinned or not, always builds fresh immediately before
it deploys, so there is one code path instead of two.

Operationally, this means a plan no longer proves the code builds or passes
tests.
It is a diff/preview, nothing more. If you want that assurance before
merging, or before creating a deployment plan, run
bear validate first — unchanged, still executes
languages.<lang>.steps, still has no environment or deployment semantics.
bear validate and bear apply's build phase run the exact same steps, so
validate is exactly the "does this build/test" check plan used to accidentally
provide, now available explicitly and reusable in PR/MR CI, independent of any
environment. The full recommended chain is doctor → validate → plan →
apply.

Plan Output

Plan output no longer has a "Validating N artifacts" phase, no progress bar, and
no "Validation complete"/"Validation failed" lines: it goes straight from the
branding header to the summary.

Bear Plan
─────────

────────────────────────────────────────
Environment: prd
Commit:      0621256
Changes:     1 file

deploy (1):
  - api (services/api): dependency 'shared' changed

changed (2):
  - shared (libs/shared): new artifact
  - worker (services/worker): new artifact

skip (1):
  - worker (services/worker): deployment not enabled for environment prd

Plan complete: 3 changed, 1 to deploy, 1 skipped

Run 'bear apply' to execute this plan.

There is a new third summary section, changed (N):, between deploy and
skip: it lists artifacts and libraries that changed but have nothing to
deploy — most commonly a library, since libraries are never deployable — and it
is informational only, never persisted to .bear/plan.yml. The closing sentence
changed from Plan complete: N validated, M to deploy[, K skipped] to
Plan complete: N changed, M to deploy[, K skipped].

Apply Output

There is no more separate "Validating N artifacts" phase before deploying (that
only ever existed for pinned plans before). Now there is exactly one phase,
Deploying N artifact(s) to <env>, and each artifact's step counter spans build
and deploy steps together:

Bear Apply
──────────

Deploying 1 artifact to prd

  api: Deploying...
  api: Deploying... [1/4 Test]
  api: Deploying... [2/4 Build]
  api: Deploying... [3/4 Build image]
  api: Deploying... [4/4 Push image]
  api: Deployment complete after 0s

Apply complete: 1 deployed, 1 skipped in 0s

Here api's language contributes the first two steps (Test, Build) and its
target contributes the last two (Build image, Push image); apply numbers all
four as one sequence rather than resetting the counter when deployment starts.

A failing build step fails apply exactly like a failing deploy step, reported in
failed (N): with the step name in the reason:

────────────────────────────────────────
Environment: prd

failed (1):
  - api (services/api): Test: exit status 1

Apply failed: 0 deployed, 1 failed, 1 skipped in 0s

Schema (.bear/plan.yml)

  • PlanFile gained a version field (CurrentPlanFileVersion, currently 1),
    stamped by every plan and checked by apply's very first preflight step, before
    anything else in the plan is trusted.
  • PlanArtifact gained build_steps (the language steps, run first by apply)
    alongside the existing steps (target deploy steps, run second by apply).
  • PlanFile.validated was renamed to changed (a count of artifacts affected by
    a source change, not "validated" — nothing validates during plan anymore).
  • The old validations list (PlanValidation) is gone entirely — it existed
    only to replay validation in a pinned apply's fresh worktree; that mechanism
    no longer exists because all applies now run build steps for every deploying
    artifact.

!!! note "Plans created before this release are rejected, not misapplied"
A plan written by a pre-upgrade binary has no version field, so the new
bear apply refuses it before running anything:

```text
Error: unsafe saved plan: schema version 0 (want 1); run 'bear plan <environment>' again
```

If you see this, just run `bear plan <environment>` again — there is no
silent-misapply risk. See the
[v5 upgrade guide](../migration-v5.md#plan-no-longer-builds-apply-now-does).

--pin No Longer Validates

bear plan --pin used to run the pinned commit's build steps in its private
worktree. It now only resolves the ref and takes its fingerprint there — it runs
no commands. bear apply builds and deploys a pinned artifact exactly like a
normal one, fresh, every time. If you need assurance a pinned revision builds
before you get to apply — for example ahead of a release freeze — run
bear validate against it explicitly. Validate has no ref/pin concept of its
own, but it does accept -d <path>, so the workaround is to check the revision
out and validate that directory:

git worktree add /tmp/pin-check abc1234
bear validate -d /tmp/pin-check
git worktree remove /tmp/pin-check

See bear plan's --pin section
for the full explanation.

Retiring an Environment

Removing a name from environments does not touch bear.lock.yml. Its history under
that key is kept, and is neither an error nor a warning — bear doctor says nothing
about it. bear list and bear list --tree report the declared set, so retiring an
environment hides its history from those views without deleting it. Restore the name
and it reappears.

The one thing that does fail is an artifact allowlist still naming the retired
environment. Fix those when you retire a name.

bear check Renamed To bear doctor

bear check is renamed to bear doctor, with no alias — running bear check
now fails with unknown command "check" for "bear". Update every script, CI job,
and alias that runs it.

check was an overloaded, ambiguous verb sitting right next to bear validate:
both names could plausibly mean "does this build," which is exactly what
validate does and this command deliberately does not. doctor is the idiom
several other CLIs already use for a single, side-effect-free diagnostic pass
over configuration — brew doctor and flutter doctor chief among them — and
that is precisely this command's job: load the config, then check languages,
targets, artifacts, environments, dependencies, and cycles, and run nothing else.

The output wording changed to match. The phase heading is now
Diagnosing configuration (it was Validating configuration), and the closing
error line is now Doctor found N error(s) (it was Check failed with N error(s)). Per-step verbs are unchanged — Checking / Still checking /
Check complete / Check failed still label each step, and a clean run still
prints All checks passed!:

Bear Doctor
───────────

Diagnosing configuration

  Loading config:        Checking...
  Loading config:        Check complete after 0s
  Checking languages:    Checking...
  Checking languages:    Check complete after 0s
  Checking targets:      Checking...
  Checking targets:      Check complete after 0s
  Scanning artifacts:    Checking...
  Scanning artifacts:    Check complete after 0s
  Checking environments: Checking...
  Checking environments: Check complete after 0s
  Checking dependencies: Checking...
  Checking dependencies: Check complete after 0s
  Checking for cycles:   Checking...
  Checking for cycles:   Check complete after 0s

  Environments: dev, int, prd

  All checks passed!

See the v5 upgrade guide
for the checklist entry.

bear validate

bear validate                       # Validate every artifact and library
bear validate user-api order-api    # Validate exactly these
bear validate --environment int     # Inject ENVIRONMENT=int into the steps
bear validate --concurrency 5       # Limit parallel validation jobs

Validate runs the validation steps of every discovered artifact and library
against the current working tree and reports which ones pass:

Bear Validate
─────────────

Validating 4 artifacts

  shared:             Validating...
  kira-teams-adapter: Validating... [1/2 Test]
  checkout-api:       Validating... [2/2 Build]
  checkout-api:       Validation complete after 3s

Validation complete: 4 artifacts in 3s

Naming artifacts validates exactly those. Dependencies are never added, so
bear validate checkout-api does not also validate the shared library it
depends on, and a repeated name runs once. A name matching nothing is an error, so
a typo fails the job instead of quietly validating nothing:

Error: unknown artifact "chekout-api"

Several misses are reported together and sorted, as
unknown artifact "other", "typo", and an unmatched name rejects the whole
selection before the first step runs.

An artifact whose language defines no validation steps is reported as
no validation steps and completes successfully, which keeps a silently
unvalidated artifact visible without turning a deliberate configuration into a
failure.

A failing run reopens the summary with the failures only, the way a failed apply
reports, and exits nonzero:

────────────────────────────────────────

failed (2):
  - checkout-api (services/checkout-api): Test: exit status 1
  - shared (libs/shared): Build: exit status 2

Validation failed: 2 passed, 2 failed in 4s

doctor → validate → plan → apply

The command chain is now bear doctor for configuration, bear validate for the
merge request, bear plan <environment> for deployment review and approval, and
bear apply for execution.

bear plan runs no commands at all — see
The Plan/Apply Execution Model Change
above. Validate is not a duplicate of a check plan performs; it is the only
place that check happens before bear apply performs it again, for real,
immediately before each deployment. Run it in the pull request for fast
feedback, where there is no environment to choose and nothing to approve.

Validation Without Deployment Semantics

Validate deliberately has none of plan's deployment machinery:

  • No environment argument. Every positional is an artifact name, so
    bear validate int fails with unknown artifact "int". --environment is
    optional and only injects ENVIRONMENT into the steps, with the same precedence
    plan uses, so a step behaves identically in a merge request and in a deployment.
    It selects no policy and produces no verdict, and a value the project does not
    declare is rejected before the workspace is touched.
  • No deployment policy. environments allowlists gate nothing. An artifact
    that may never deploy anywhere is still validated. They are still checked against
    the project's declared environments, because that is a configuration error rather
    than a policy decision.
  • No change detection. Every selected artifact runs, changed or not.
  • No deployment history. bear.lock.yml is neither read nor written.
  • No plan. .bear/plan.yml is neither read, written, nor removed, so
    validating cannot invalidate an approval an earlier bear plan produced.
  • No deploy or skip output. No Environment: fact block, no
    deploy (/skip ( sections, no Run 'bear apply' hint.
  • No Git. Validate never shells out to Git, so it works in a shallow clone, a
    single-commit CI checkout, or a plain export that is not a repository at all. It
    cannot require clean source, because it never looks.

It does take the nonblocking .bear/workspace.lock for the project root, because
it reads a working tree a concurrent plan or apply may be rewriting, and it fails
immediately rather than waiting. It takes no repository lock: it runs no Git and
publishes nothing.

The global -d/--dir and -v/--verbose apply, and --concurrency defaults to
10 like plan and apply. The deployment flags are not accepted: --pin,
--no-commit, --git-remote and --git-branch fail with unknown flag.

What Validate Costs

Validate does not scope work to the changed files. It validates everything, or
exactly the artifacts you name. In a large monorepo that is real time on every
pull request, and Bear offers exactly two levers: name the artifacts a job should
cover, and tune --concurrency. Bear does not infer the affected set from a base
ref, a diff, or CI metadata, and this release does not add change detection to
validate.

Console output remains an execution log, not an audit record: failure tails are
bounded and never redacted, and --verbose streams whatever the configured step
writes.

CI Templates

Merge Request Validation adds
merge/pull-request jobs for GitHub Actions, GitLab CI and Jenkins. They take no
deployment credentials, no environment and no Git history — a default shallow
checkout is enough — and they must never run bear apply, because the job that
runs untrusted change-request code is exactly the job that must hold no
deployment secrets.

examples/Jenkinsfile and examples/Jenkinsfile.docker gained a Validate stage
guarded by changeRequest() and no credential binding. The Plan stage now
carries the complementary not { changeRequest() } guard, so a change request
validates instead of producing a production plan it can never apply. The
host-agent template's Bear installation moved into its own Install stage so both
paths share it. The trusted-main deploy stage, its branch allowlist, its ref
validation and its gitUsernamePassword binding are unchanged. The GitLab
template's merge-request job now runs bear validate in place of bear plan dev.

What Did Not Change

  • bear.lock.yml. No new field, no renamed key, no migration. History under an
    environment that is no longer declared is kept.
  • .bear/plan.yml's allowlist/policy/source-safety fields. The environment,
    allowlist, commit, and fingerprint fields are exactly as before. What did
    change is covered in
    The Plan/Apply Execution Model Change:
    version and build_steps are new, validated is renamed changed, and
    validations is gone. Plans written before this release are rejected by
    the new bear apply
    — see the note above; run bear plan <environment>
    again.
  • bear apply's environment/policy checks. No new check, no configuration
    read, no new flag related to the environments declaration. Its execution
    did change — it now runs build steps before deploy steps for everything it
    deploys — which is the subject of this release's other breaking change.
  • bear.artifact.yml and bear.lib.yml schemas. The artifact environments
    allowlist is the same field with the same meaning; only its permitted values are now
    project-defined. bear.lib.yml still has no environments field, and strict
    decoding still rejects one.
  • Everything else. Change detection, dependency propagation and cycle rejection,
    the fingerprint contract itself, pinned worktrees, retries and checkpointing, Git
    publication, locking, and presets are as described in the
    v4.1.0 and v4.0.0 release notes — only when build
    steps run relative to them changed, not how they work. The
    v4 migration guide still describes the move to per-artifact
    allowlists and environment-scoped history.

Install and Upgrade

Pin the release instead of automatically moving to latest:

git clone --branch v5.0.0 --depth 1 https://github.com/irevolve/bear.git bear-v5
go -C bear-v5 install -ldflags="-X github.com/irevolve/bear/commands.Version=5.0.0" .

Use Go 1.25+ and put the Go install directory on PATH. Platform binaries are
listed on the v5.0.0 release.
Container versions are ghcr.io/irevolve/bear:5.0.0, :5.0.0-alpine, and
:5.0.0-debian; see agent requirements
before using them as CI images. Read the v5 migration guide
before upgrading an existing monorepo — declare environments: and update every
artifact's allowlist before your next plan, and expect any plan file saved before
this release to be rejected rather than applied.

Full Changelog: v4.1.0...v5.0.0