Skip to content

Latest commit

 

History

History
119 lines (81 loc) · 6.6 KB

RELEASING.md

File metadata and controls

119 lines (81 loc) · 6.6 KB

Releasing

How nwidart/laravel-modules releases are made. The automation lives in:

  • .github/workflows/release.yml: computes the next version and opens a release PR.
  • .github/workflows/tag-release.yml: tags the release and publishes the GitHub release when that PR is merged.
  • cliff.toml: git-cliff configuration. It turns commit messages into a version bump and a CHANGELOG section.

Version policy

The package major tracks the Laravel major: 13.x supports Laravel 13, 12.x supports Laravel 12.

Release When Example
Major A new Laravel major is supported. Made by hand, see New major release. v14.0.0
Minor At least one feat commit since the last tag. v13.1.0
Patch Only fix, perf, refactor, docs, or other commits. v13.0.1

The version comes from the commit messages, so commits must follow Conventional Commits. CI checks this on every pull request.

Branches:

  • master releases the current major. composer.json extra.branch-alias says which one (13.x-dev).
  • N.x (for example 12.x) is the maintenance branch of an older major.

Tags are vX.Y.Z. Each branch only sees the tags reachable from it, so a 12.x release continues from the latest v12 tag.

Cut a release (minor or patch)

  1. Go to Actions > Release > Run workflow.
  2. Pick the branch: master, or a maintenance branch such as 12.x.
  3. Pick bump:
    • auto (default): feat commits give a minor release, anything else gives a patch release.
    • minor or patch: force that bump.
  4. The workflow opens a PR chore(release): vX.Y.Z from release/vX.Y.Z. The PR adds the new section to CHANGELOG.md and shows it in the PR body.
  5. Review the CHANGELOG section. To change it, push commits to the release branch. The GitHub release notes are read from CHANGELOG.md when the PR is merged.
  6. Merge the PR. tag-release.yml then:
    • creates the annotated tag vX.Y.Z on the merge commit and pushes it,
    • creates the GitHub release vX.Y.Z with the CHANGELOG section as notes (marked "Latest" only for master releases),
    • deletes the release branch.
  7. Packagist picks up the tag through its GitHub webhook. Nothing else to do.

Merge the release PR soon. Commits that land on the branch between the workflow run and the merge are part of the tag but are not listed in its CHANGELOG section.

The Release workflow stops with an error when:

  • it runs on a branch other than master or N.x,
  • there are no releasable commits since the last tag (merge commits, chore(release), Pint style commits, and Dependabot commits do not count),
  • a breaking change (feat!: or BREAKING CHANGE:) would bump the major: rerun with bump=minor or bump=patch, or make a major release,
  • the major in composer.json extra.branch-alias differs from the latest tag on the branch (a new major was prepared but not tagged yet),
  • the tag vX.Y.Z or the branch release/vX.Y.Z already exists.

Preview locally

With git-cliff installed, from the branch you want to release:

git fetch --tags
git-cliff --use-branch-tags --bumped-version              # next version
git-cliff --use-branch-tags --unreleased --strip all       # next CHANGELOG section

RELEASE_TOKEN (optional)

By default the workflows use GITHUB_TOKEN. GitHub does not start workflows for pushes and PRs made with GITHUB_TOKEN, so the release PR shows no CI checks. Tags pushed with it still fire repository webhooks, so Packagist is not affected.

To get CI on release PRs, add a repository secret RELEASE_TOKEN: a fine-grained personal access token or GitHub App token for this repository with Contents: read and write and Pull requests: read and write. release.yml uses it when it is set.

What changes in a release

Every release

  • A new section in CHANGELOG.md (generated by release.yml).
  • The tag vX.Y.Z on the merged release PR.
  • A GitHub release for the tag.
  • Packagist update, through the webhook.

Nothing in composer.json changes. It has no version key: Composer and Packagist read the version from the tag, and php artisan about reads it from Composer.

New major release

A new major follows a new Laravel major and is not made by the Release workflow. The Laravel upgrade PR on master makes these changes:

  • composer.json: laravel/framework, orchestra/testbench, and php constraints.
  • composer.json: extra.branch-alias.dev-master (13.x-dev to 14.x-dev).
  • README.md: compatibility table.
  • AGENTS.md: the "master branch targets Laravel N" line.
  • .github/workflows/php.yml: PHP version matrix.

Before merging the upgrade PR, create the maintenance branch of the current major from its latest tag, so fixes for it can still be released:

git fetch --tags
git switch -c 13.x v13.0.5   # latest v13 tag
git push origin 13.x

The new 13.x branch has the release workflows of that tag. If they are missing or outdated, port them as described in Maintenance branches.

After the upgrade PR is merged:

  1. Add a ## 14.0.0 - YYYY-MM-DD section to CHANGELOG.md below the intro, in a chore(release): v14.0.0 commit (git-cliff --use-branch-tags --unreleased --tag v14.0.0 --strip all drafts it).
  2. Tag that commit and push the tag: git tag -a v14.0.0 -m v14.0.0 && git push origin v14.0.0.
  3. Create the GitHub release: gh release create v14.0.0 --title v14.0.0 --notes-file <section>.

Later minor and patch releases on master use the Release workflow again.

Maintenance branches

GitHub runs a dispatched workflow from the branch it is dispatched on, and a pull_request workflow from the PR merged into its base branch. A maintenance branch can use the release automation only when it has its own copies of:

  • .github/workflows/release.yml
  • .github/workflows/tag-release.yml
  • cliff.toml
  • the commits job and the Pint commit message (style: apply pint fixes) from .github/workflows/php.yml

12.x does not have them yet. Cherry-pick the commit that adds release.yml, tag-release.yml, cliff.toml, and this file to 12.x before the first automated 12.x release. The php.yml on 12.x is older and laid out differently from master, so port the commits job and the Pint commit message by hand.

origin/12.x composer.json has extra.branch-alias "dev-master": "12.x-dev". Composer ignores that alias on a branch named 12.x, because the branch already resolves to 12.x-dev. The Release workflow reads only the alias value (12.x-dev), so it works either way.