Release automation
Release automation moves a reviewed version change from the master or alpha branch to npm and GitHub Releases. It keeps the version in the workspace, the release pull request, the changelog, the git tag, and the npm channel in agreement while leaving maintainers in control of the final merge. The published package and its build output are described in Packaging and distributable builds, and the release checks connect with the broader test and fixture system.
Release lanes
The repository has two automated release lanes for the main product and one local prerelease utility. The branch selects the version shape and npm channel, so a release cannot silently move an alpha version into the stable channel.
Stable releases
The master lane publishes a normal semantic version such as X.Y.Z to npm under the latest tag. The release pull request carries the version change before merge; after merge, the publisher uses that version as-is rather than creating a new branch commit.
This order makes the published git tag point at a commit that is already on master. The workflow also creates or updates a non-prerelease GitHub Release and attaches the built browser files.
References: .github/…/publish.yml• L3-12 .github/…/publish.yml• L178-241 scripts/bump-and-publish.js• L164-225 scripts/bump-and-publish.js• L241-265
Alpha releases
The alpha lane publishes versions in the form X.Y.Z-alpha.N under npm's alpha dist-tag. It requires alpha to include all commits from master and to use a base version that is not lower than the stable version.
Alpha uses the same release pull request and merge-to-publish path as stable releases. Its GitHub Release is marked as a prerelease, and its notes show the alpha installation form. An older alpha title prefix remains valid for existing pull requests, but new metadata uses the common chore: release v... shape.
References: .github/…/publish.yml• L29-35 .github/…/publish.yml• L97-173 .github/…/publish.yml• L192-241 scripts/release-metadata.js• L10-20 scripts/release-metadata.js• L56-79 scripts/bump-and-publish.js• L195-211
Beta publications
The beta utility is a local, direct publication path rather than a branch-based release workflow. It reads the current stable npm version, selects the next patch with a -beta.0 suffix, updates versioned packages, builds the product, and publishes the non-private packages under the beta tag.
Maintainers can use a different npm tag or skip the test step when needed. A dry run still performs the build but does not update package files or publish to npm.
References: package.json• L7-18 scripts/publish-beta.js• L1-15 scripts/publish-beta.js• L63-115
Version metadata
Release metadata is the shared contract for version names, branch names, pull request titles, and release checks. The scripts/release-metadata.js command accepts a branch and version as its main inputs so workflows do not each define their own release rules.
Version rules
Stable and alpha versions use different semantic-version rules. The same rules apply when a workflow creates a release pull request and when the publish workflow checks the merged pull request.
| Release base | Version shape | npm channel | Release type |
|---|---|---|---|
master | X.Y.Z | latest | Stable |
alpha | X.Y.Z-alpha.N | alpha | Prerelease |
The requested version must be greater than the matching npm version. It must also be at least as high as the version already present on the release branch when the title-sync check runs.
References: scripts/release-metadata.js• L14-20 scripts/release-metadata.js• L32-102 .github/…/create-release-pr.yml• L83-97 .github/…/create-release-pr.yml• L257-272
Version selection
The release PR workflow selects the next version from the branch package version and the matching npm channel. Stable releases normally take the next patch after npm. If the branch already has a higher version, the workflow keeps that version. Alpha releases increase the alpha number from the higher known version, or start the next major alpha series when the branch has no alpha suffix.
This selection prevents a stale branch from reusing an already published version. It also lets a release PR remain open while new changes land without losing the version that its title requests.
References: scripts/release-metadata.js• L104-125 .github/…/create-release-pr.yml• L57-92 scripts/test-release-automation.js• L664-703
Version synchronization
Version synchronization makes every package manifest carry the release version. It also keeps the top changelog release heading aligned with the pull request title, or inserts a new heading when the current history does not match.
The synchronization runs in two places. Release PR creation prepares the version commit, while the title-sync job repairs the release branch when a maintainer edits the title. The title-sync job reads the trusted metadata script from the target branch so the branch validates its title against the release rules that will publish it.
References: scripts/release-metadata.js• L127-143 scripts/release-metadata.js• L183-228 .github/…/create-release-pr.yml• L104-153 .github/…/create-release-pr.yml• L248-304
Release pull requests
Release pull requests are the review boundary for version changes. Normal code changes cause the automation to prepare or refresh one release branch and pull request for the target branch; maintainers merge that pull request to authorize publication.
Release PR creation
The creation job watches pushes to master and alpha. It finds an existing repository-owned release pull request for the target branch when one exists. Otherwise, it creates a versioned release branch, commits synchronized package metadata, adds merged pull request entries to the changelog, and opens the pull request with a short body that states the merge effect.
The branch is rebuilt from the latest target branch before the version commit. This lets an open release pull request include new work that arrived after the previous release-PR update. If the requested version already matches the branch, the job exits without creating an empty commit or pull request.
References: .github/…/create-release-pr.yml• L3-18 .github/…/create-release-pr.yml• L57-97 .github/…/create-release-pr.yml• L104-199 scripts/release-metadata.js• L23-30
Release PR title synchronization
The title-sync job treats the pull request title as the visible source of the requested release version. It accepts only a repository-owned release branch with the matching target branch, parses the title, validates it against npm and the current branch version, and then updates package manifests and the changelog when needed.
This repair step protects the link between review text and release files. A title change to a lower or already published version fails before it can create a misleading release commit.
References: .github/…/create-release-pr.yml• L202-226 .github/…/create-release-pr.yml• L257-304 scripts/release-metadata.js• L32-102
Alpha version recovery
The alpha branch has a separate recovery helper for merges that overwrite its prerelease version with a stable one. It finds the most recent alpha version in branch history, increases its alpha number, and updates the workspace manifests for a maintainer to commit.
This helper is a repair path rather than the normal release path. The normal path keeps alpha versions in the release PR and checks the branch before publication.
References: scripts/post-merge-version-fix.js• L3-10 scripts/post-merge-version-fix.js• L48-76 scripts/post-merge-version-fix.js• L98-145
Publication workflows
The GitHub workflows separate release preparation from release delivery. Preparation creates a reviewed version commit, while delivery runs only after a matching release pull request merges into an allowed branch.
Merge-to-publish flow
The diagram shows how a normal branch change becomes a reviewed release and then a tagged npm and GitHub delivery.
flowchart LR
A[Change merged to master or alpha] --> B[Create or refresh release PR]
B --> C[Sync title and release files]
C --> D[Maintainer merges release PR]
D --> E[Validate branch, title, package version, and npm version]
E --> F[Run Node tests and build]
F --> G[Create and push git tag]
G --> H[Publish packages to npm]
H --> I[Create or update GitHub Release]
The publish workflow listens for closed pull requests but continues only for a merged release PR in the less/less.js repository. It checks that the title version matches packages/…/package.json, confirms that the version is newer than npm, runs the Node test set and distribution build, and then publishes all non-private packages.
References: .github/…/create-release-pr.yml• L24-37 .github/…/publish.yml• L3-36 .github/…/publish.yml• L60-91 .github/…/publish.yml• L175-241 scripts/bump-and-publish.js• L228-239
Local stable publication
The root publish command is the stable and alpha publisher used by the GitHub workflow. It accepts only master or alpha, checks the branch's existing package version against the matching npm channel, creates an annotated version tag, and publishes each non-private package with the branch's npm tag.
The publisher does not make a second branch commit or push a branch. This keeps the tag attached to the already merged release-PR commit. publish:dry-run exercises the same decisions without changing the repository or registry.
References: package.json• L7-18 scripts/bump-and-publish.js• L164-181 scripts/bump-and-publish.js• L185-265 scripts/bump-and-publish.js• L330-410
GitHub release delivery
After npm publication, the workflow creates a GitHub Release for the same tag. Stable releases use normal release notes and alpha releases use prerelease notes with the matching npm installation command.
The release includes the built less.js and minimized browser files. If the tag already has a GitHub Release, the workflow updates that release's assets instead of creating a duplicate.
References: .github/…/publish.yml• L192-241 packages/…/package.json• L46-54
Delivery checks
Release automation has a focused offline test command that checks the contracts most likely to cause an unsafe or looping release. It does not require live GitHub or npm credentials for its workflow-condition, version-rule, dry-run, and no-op checks.
Release contract checks
The release test suite checks that only the intended repository and merged release titles can publish. It also checks that normal branch changes create release work without retriggering on release commits, that alpha numbering handles rollover and major changes, and that version bumps create commits only when files change.
The suite includes a package-manager compatibility check because the GitHub workflows install the pnpm version declared by the root package while reading the repository lockfile. This protects workflow setup from a silent mismatch between the declared tool version and the lockfile format.
References: package.json• L15-18 scripts/test-release-automation.js• L1-38 scripts/test-release-automation.js• L94-160 scripts/test-release-automation.js• L906-1019
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the version shapes, title prefixes, release branch names, and npm dist-tags aligned across scripts/release-metadata.js, create-release-pr.yml, and publish.yml.
- Keep the package-version sync scope aligned with the packages that the publisher considers publishable. A new versioned package can otherwise enter the workspace with no matching release version.
- Keep title synchronization based on the target branch's release rules. A release PR can otherwise pass its repair step but fail after merge.
- Keep the alpha branch checks aligned with the rule that alpha must include
masterand must not publish a base version below stable. - Keep the release build outputs and the GitHub Release asset paths aligned with the package build contract described in Packaging and distributable builds.
- Keep the declared pnpm version compatible with pnpm-lock.yaml when changing workflow setup or dependency state.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A release title names a version that differs from the package manifest | The publish job stops before npm publication | Title synchronization updates the release files, and publish validates the title against packages/…/package.json |
| A stable release uses a prerelease version or an alpha release uses a non-alpha version | Metadata validation or publication fails instead of sending the version to the wrong channel | release-metadata.js validates the branch-specific version shape and the publisher validates the npm tag |
| The requested version is not greater than the matching npm version | The release stops rather than reusing an existing version | Compare the title version with npm latest or npm alpha before publication |
Alpha is behind master or its base version is lower than stable | An alpha release can omit stable changes or move its version backward | The publish workflow checks branch ancestry and compares the alpha base version with master |
| A release merge triggers release-PR creation again | The automation can create a release loop | The creation job ignores release commit messages and release branch references |
| The lockfile needs a newer pnpm major than package.json declares | Workflow dependency installation fails before release work starts | Keep packageManager compatible with the lockfile version |
| A package publish fails after the git tag is pushed | The registry and git release state can be incomplete | The publisher reports failed packages and requires manual completion for the remaining packages |
Key files
| File | Why to read it |
|---|---|
| .github/…/create-release-pr.yml | Defines release PR creation, title synchronization, version-file updates, and changelog preparation. |
| .github/…/publish.yml | Defines merge-to-publish conditions, release validation, build checks, npm publication, and GitHub Release creation. |
| scripts/release-metadata.js | Defines the shared version, title, branch, validation, and synchronization contract. |
| scripts/bump-and-publish.js | Defines the stable and alpha publication handoff after a release PR merge. |
| scripts/publish-beta.js | Defines the local beta publication path and its npm tag behavior. |
| scripts/post-merge-version-fix.js | Defines recovery for an alpha version overwritten by a merge. |
| scripts/test-release-automation.js | Checks release triggers, version rules, publisher dry runs, no-op safety, and workflow tool compatibility. |
| package.json | Exposes the release commands and declares the pnpm version used by the workflows. |
| packages/…/package.json | Holds the product version and connects package publication with build and test checks. |
| pnpm-lock.yaml | Defines the dependency lock format that must remain compatible with the workflow's pnpm version. |
| CHANGELOG.md | Receives the release entry prepared by release pull request automation. |