← Workflows

阅读中文版本

Hotfix Patch Release Workflow

Branch from the exact production tag, apply the minimal fix, run targeted tests, and release a patch without pulling in unreleased work.

intermediate~60 minreleasehotfixops

Objective

Deliver a minimal, auditable hotfix to production from the released commit rather than the main branch tip.

Environment

  • A production tag or commit hash
  • Access to cut a release branch
  • CI access for the release pipeline

Steps

1. Branch from the production tag

Create a hotfix branch from the exact tag currently running in production, not from main.

Expected state: The branch contains only released code plus the fix to come.

2. Apply the minimal fix

Make the smallest change that resolves the incident and add a regression test that fails without it.

Expected state: A single focused commit with an accompanying test exists.

3. Run targeted and smoke tests

Run the affected test suites and a smoke suite against a staging build of the hotfix.

Expected state: Targeted tests pass and the critical journey works on staging.

4. Release the patch and back-merge

Tag the patch release, deploy it, then merge the fix back into main so it is not lost.

Expected state: Production runs the patch and main contains the same fix.

Decision points

Hotfix from tag or from main?

  • Branch from the production tag
  • Ship main tip

Branch from the tag so unreleased work cannot leak into production.

Patch now or wait for the scheduled release?

  • Patch immediately
  • Bundle with the next release

Patch immediately when users are impacted; otherwise bundle to avoid extra risk.

Expected outcome

A narrowly scoped patch release reaches production quickly while the fix is preserved on the mainline for future releases.

Verification

Confirm the deployed commit matches the hotfix tag, the regression test passes, and a back-merge commit exists on main.

Cleanup

Delete the hotfix branch after back-merge and record the release note linking the incident ticket.

Overview

Deliver a minimal, auditable hotfix to production from the released commit rather than the main branch tip.

This workflow is reusable across teams and environments; adapt the commands to your tooling while keeping the sequence and checkpoints intact.

Environment and prerequisites

  • A production tag or commit hash
  • Access to cut a release branch
  • CI access for the release pipeline

Procedure

1. Branch from the production tag

Create a hotfix branch from the exact tag currently running in production, not from main.

Expected state: The branch contains only released code plus the fix to come.

2. Apply the minimal fix

Make the smallest change that resolves the incident and add a regression test that fails without it.

Expected state: A single focused commit with an accompanying test exists.

3. Run targeted and smoke tests

Run the affected test suites and a smoke suite against a staging build of the hotfix.

Expected state: Targeted tests pass and the critical journey works on staging.

4. Release the patch and back-merge

Tag the patch release, deploy it, then merge the fix back into main so it is not lost.

Expected state: Production runs the patch and main contains the same fix.

git fetch --tags
git switch -c hotfix/incident-4821 v1.8.3
git commit -am 'fix: guard null invoice owner'
git push -u origin hotfix/incident-4821

Verification

Confirm the deployed commit matches the hotfix tag, the regression test passes, and a back-merge commit exists on main.

Decision points

Hotfix from tag or from main?

  • Branch from the production tag
  • Ship main tip

Recommendation: Branch from the tag so unreleased work cannot leak into production.

Patch now or wait for the scheduled release?

  • Patch immediately
  • Bundle with the next release

Recommendation: Patch immediately when users are impacted; otherwise bundle to avoid extra risk.

Common failures

  • Branching from main drags in unrelated changes.
  • No regression test means the bug can return.
  • Skipping the back-merge loses the fix on future releases.