Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish

# Releases the package versions not on npm yet, on every push to main: merging
# an approved release pull request (`pnpm release:publish`) publishes it, with
# an approved release pull request (`pnpm release:prepare`) publishes it, with
# no other manual step.
#
# `cl-release ship --plan` finds the versions not on npm and the commit that
Expand Down Expand Up @@ -145,6 +145,12 @@ jobs:
node "$CL_RELEASE" manifest "$dir"
done

# The release tags are annotated: git needs an identity to create them
- name: Git identity of the release tags
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Tag, publish to npm and release
id: ship
run: node "$CL_RELEASE" ship
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
export default {
extends: ['@commitlint/config-conventional'],
// The release commits are written by `pnpm release:publish` and list
// The release commits are written by `pnpm release:prepare` and list
// every released tag in the header, well past the length limit
ignores: [(message) => message.startsWith('chore(release): ')],
// Merge commits ("Merge branch 'main' into …") are allowed in a pull
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "biome check --enforce-assist=true",
"check": "biome check --enforce-assist=true --write",
"release:config": "cl-release labels",
"release:publish": "cl-release version",
"release:prepare": "cl-release version",
"generate": "pnpm -r --if-present generate",
"generate-local": "pnpm -r --if-present generate-local",
"check:packages": "node scripts/check-packages.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Private workspace package, not published. The release tooling of the monorepo, r

## Releasing

1. `pnpm release:publish` bumps the changed packages and opens the `chore(release)` pull request, with the release notes of each package in its description.
1. `pnpm release:prepare` bumps the changed packages and opens the `chore(release)` pull request, with the release notes of each package in its description.
2. A reviewer approves it, and it is merged.
3. publish.yml, on the push to main, publishes the versions not on npm (`cl-release ship`): it builds and tests them from the commit that set them, then, dependencies first, tags each version, publishes it to npm (OIDC, provenance) and publishes its GitHub release. Each package published to npm gets its own Slack message, with the link to its release notes.

Expand All @@ -13,7 +13,7 @@ A release that stopped halfway resumes by running publish.yml by hand: what is o
## Commands

```sh
cl-release version [--interactive | --yes] [--base <b>] [--no-pr] [--dry-run] # pnpm release:publish
cl-release version [--interactive | --yes] [--base <b>] [--no-pr] [--dry-run] # pnpm release:prepare
cl-release ship [--plan] [--dry-run] # publish.yml
cl-release tag [--base <b>] [--no-push] [--dry-run] # manual recovery
cl-release try [<plugin dir>...] [--out <dir>] # pnpm release:try
Expand Down
4 changes: 2 additions & 2 deletions packages/release/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* cl-release: the release tooling of the monorepo.
*
* The root scripts run it (`pnpm release:publish`, …), and the workflows call
* The root scripts run it (`pnpm release:prepare`, …), and the workflows call
* its commands directly (`pnpm exec cl-release resolve <tag>`, …). It works
* from anywhere in the repository: it runs at the workspace root.
*/
import { execFileSync } from 'node:child_process'

const COMMANDS = {
version: ['Bump the changed packages and open the release pull request (pnpm release:publish)', () => import('./commands/version.ts')],
version: ['Bump the changed packages and open the release pull request (pnpm release:prepare)', () => import('./commands/version.ts')],
ship: ['Tag, publish to npm and release the versions not on npm (publish.yml)', () => import('./commands/ship.ts')],
tag: ['Tag the versions not released yet and push the tags (manual recovery: ship tags them)', () => import('./commands/tag.ts')],
try: ['Install the working tree in a sandbox, packed as for npm', () => import('./commands/try.ts')],
Expand Down
2 changes: 1 addition & 1 deletion packages/release/src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const dependenciesToPublish = (
const depTag = tagOf(dep)
if (!tags.has(depTag))
throw new Error(
`${[...chain, p.name].join(' → ')} needs ${dep.name}@${dep.version}, which is not on npm and has no ${depTag} release tag. Release it with \`pnpm release:publish\`.`,
`${[...chain, p.name].join(' → ')} needs ${dep.name}@${dep.version}, which is not on npm and has no ${depTag} release tag. Release it with \`pnpm release:prepare\`.`,
)
visit(dep, [...chain, p.name])
toPublish.push(dep)
Expand Down
4 changes: 2 additions & 2 deletions packages/release/src/commands/ship.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Releases the package versions not on npm yet: run by publish.yml on every
* push to main, so merging an approved release PR (`pnpm release:publish`)
* push to main, so merging an approved release PR (`pnpm release:prepare`)
* publishes it, with no other manual step.
*
* --plan finds them: the public packages whose package.json version isn't on
Expand Down Expand Up @@ -119,7 +119,7 @@ export const run = async (args: string[]): Promise<void> => {
for (const name of workspaceDeps(pkg)) {
const dep = all.get(name)
if (dep && !names.has(name) && !onNpm(dep.name, dep.version))
fail(`${pkg.name} needs ${dep.name}@${dep.version}, which is neither on npm nor in this release. Release it with \`pnpm release:publish\`.`)
fail(`${pkg.name} needs ${dep.name}@${dep.version}, which is neither on npm nor in this release. Release it with \`pnpm release:prepare\`.`)
}
}

Expand Down
11 changes: 10 additions & 1 deletion packages/release/src/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { createInterface } from 'node:readline/promises'
import { Bumper } from 'conventional-recommended-bump'
import semver from 'semver'
import { parse } from '../args.ts'
import { fail, git, lastTag, type Package, previousRelease, publicPackages, readJson, requireUpToDate, sortByDependencies, tagOf, workspaceDeps, writeJson } from '../workspace.ts'
import { fail, git, lastTag, onNpm, type Package, previousRelease, publicPackages, readJson, requireUpToDate, sortByDependencies, tagOf, workspaceDeps, writeJson } from '../workspace.ts'
import { buildNotes } from './notes.ts'

const USAGE = `Usage: cl-release version [--interactive | --yes] [--base <branch>] [--no-pr] [--dry-run]
Expand Down Expand Up @@ -138,6 +138,15 @@ export const run = async (args: string[]): Promise<void> => {

requireUpToDate(base)

// A merged release not on npm yet (publish.yml still running, or failed):
// its tags don't exist yet, so its changes would be released a second time
const pending = publicPackages().filter((p) => !semver.prerelease(p.version) && !onNpm(p.name, p.version))
if (pending.length > 0)
fail(
`Not released yet: ${pending.map((p) => `${p.name}@${p.version}`).join(', ')}. ` +
'Wait for publish.yml to publish them (Actions → Publish; run it again if it failed), then prepare the next release.',
)

const candidates: Candidate[] = []
for (const pkg of publicPackages()) {
const since = await lastTag(pkg)
Expand Down
Loading