diff --git a/.changeset/support-maintenance-branches.md b/.changeset/support-maintenance-branches.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/support-maintenance-branches.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/actions/checks/action.yml b/.github/actions/checks/action.yml index b38cd4c9d0..03d5eed2b7 100644 --- a/.github/actions/checks/action.yml +++ b/.github/actions/checks/action.yml @@ -10,6 +10,10 @@ inputs: description: 'Ref the changeset check compares against. Leave empty to skip it, e.g. for a release.' required: false default: '' + target-branch: + description: 'Branch the checked change goes into. On "maintenance/" major bumps are rejected.' + required: false + default: '' runs: using: 'composite' @@ -41,6 +45,63 @@ runs: # Rejects unparsable frontmatter, unknown package names and invalid bump types. pnpm changeset status --since="$BASE_REF" + # A maintenance branch stays on its major; main moves on to higher majors (see + # "Check main release line"), so a major bump would collide with main's versions. + - name: Check maintenance release line + id: maintenance-check + if: ${{ startsWith(inputs.target-branch, 'maintenance/') }} + continue-on-error: ${{ inputs.perform-all-checks == 'true' }} + shell: bash + env: + TARGET_BRANCH: ${{ inputs.target-branch }} + run: | + BRANCH_MAJOR="${TARGET_BRANCH#maintenance/}" + VERSION=$(jq -r .version packages/ckeditor5-common/package.json) + if [ "${VERSION%%.*}" != "$BRANCH_MAJOR" ]; then + echo "::error::$TARGET_BRANCH only releases $BRANCH_MAJOR.x.y, but the packages have version $VERSION. A maintenance branch accepts neither major bumps nor changes based on another major." + exit 1 + fi + + MAJOR_CHANGESETS=$(node scripts/major-changesets.mjs) + if [ -n "$MAJOR_CHANGESETS" ]; then + echo "::error::Major changes are not allowed on $TARGET_BRANCH; use patch or minor:" + echo "$MAJOR_CHANGESETS" + exit 1 + fi + echo "No major changesets on $TARGET_BRANCH." + + # Counterpart on main: once maintenance/ exists (it may be created while main is + # still on that major), main must not release that major again. An unreleased version + # fails: the "Version Packages" PR and the release itself, but also main after a failed + # release. A released version only warns, so patch and minor pull requests learn early + # that they will not be released before the next major. A pending major changeset makes + # the next release major, so it passes; otherwise the pull request adding it could + # never be integrated. + - name: Check main release line + id: main-line-check + if: ${{ inputs.target-branch == 'main' }} + continue-on-error: ${{ inputs.perform-all-checks == 'true' }} + shell: bash + run: | + VERSION=$(jq -r .version packages/ckeditor5-common/package.json) + MAJOR="${VERSION%%.*}" + if ! git ls-remote --exit-code --heads origin "maintenance/$MAJOR" > /dev/null; then + echo "main may release $VERSION." + exit 0 + fi + MAJOR_CHANGESETS=$(node scripts/major-changesets.mjs) + if [ -n "$MAJOR_CHANGESETS" ]; then + echo "maintenance/$MAJOR exists, but the next release is major:" + echo "$MAJOR_CHANGESETS" + exit 0 + fi + if git rev-parse -q --verify "refs/tags/$VERSION" > /dev/null; then + echo "::warning::maintenance/$MAJOR exists, so main's next release must be major. Changes merged into main are not released until a 'major' changeset is added; fixes for $MAJOR.x.y go to maintenance/$MAJOR." + exit 0 + fi + echo "::error::maintenance/$MAJOR exists, so main must not release $VERSION: its next release must be major. Add a 'major' changeset on main." + exit 1 + - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 id: playwright-cache with: @@ -114,6 +175,20 @@ runs: FAILED=true fi + if [ "${{ steps.maintenance-check.outcome }}" == "failure" ]; then + echo "❌ Maintenance release line check failed" >> $GITHUB_STEP_SUMMARY + FAILED=true + elif [ "${{ steps.maintenance-check.outcome }}" == "success" ]; then + echo "✅ Maintenance release line check passed" >> $GITHUB_STEP_SUMMARY + fi + + if [ "${{ steps.main-line-check.outcome }}" == "failure" ]; then + echo "❌ Main release line check failed" >> $GITHUB_STEP_SUMMARY + FAILED=true + elif [ "${{ steps.main-line-check.outcome }}" == "success" ]; then + echo "✅ Main release line check passed" >> $GITHUB_STEP_SUMMARY + fi + if [ "${{ steps.unit-tests.outcome }}" == "success" ]; then echo "✅ Unit tests passed" >> $GITHUB_STEP_SUMMARY else diff --git a/.github/workflows/create-maintenance-branch.yml b/.github/workflows/create-maintenance-branch.yml new file mode 100644 index 0000000000..5dbcbd4b76 --- /dev/null +++ b/.github/workflows/create-maintenance-branch.yml @@ -0,0 +1,131 @@ +name: "Create Maintenance Branch" + +# Creates maintenance/ for an older major, so it can receive patch and minor +# releases while main moves on. The branch is a release line of its own: changesets, +# "Version Packages" PR, QA gate and release work there just like on main. +on: + workflow_dispatch: + inputs: + major: + description: 'Major version to maintain, e.g. "28" creates maintenance/28 from the latest 28.x.y release' + required: true + type: string + +permissions: + contents: read + +run-name: | + Create maintenance/${{ inputs.major }} + +jobs: + create: + name: Create maintenance/${{ inputs.major }} + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: main + fetch-depth: 0 + # Pushes to maintenance/* are restricted by the ruleset; coremedia-ci bypasses it. + token: ${{ secrets.GH_PAT_PUSH_FROM_GHA }} + + - name: Configure Git + run: | + git config user.name 'coremedia-ci' + git config user.email 'coremedia-ci@coremedia.com' + + - name: Validate + id: validate + env: + MAJOR: ${{ inputs.major }} + run: | + fail() { echo "::error::$1"; exit 1; } + + [[ "$MAJOR" =~ ^[1-9][0-9]*$ ]] || fail "\"$MAJOR\" is not a major version number." + BRANCH="maintenance/$MAJOR" + + if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null; then + fail "$BRANCH already exists." + fi + + # main may be on the same major (e.g. right before breaking changes): the checks + # action then rejects any further release of $MAJOR.x.y from main. + MAIN_VERSION=$(jq -r .version packages/ckeditor5-common/package.json) + MAIN_MAJOR="${MAIN_VERSION%%.*}" + [ "$MAIN_MAJOR" -ge "$MAJOR" ] \ + || fail "main is on major $MAIN_MAJOR; there is no release of major $MAJOR to maintain." + + # An unreleased version on main (e.g. after a failed release) would be left out of + # the branch, and main could not release it anymore. + if [ "$MAIN_MAJOR" -eq "$MAJOR" ]; then + git rev-parse -q --verify "refs/tags/$MAIN_VERSION" > /dev/null \ + || fail "main holds the unreleased version $MAIN_VERSION; release it first." + + # Changes merged into main but not yet released are not part of the branch. + # Empty changesets (no package bumps) release nothing, so they are ignored. + PENDING="" + for FILE in .changeset/*.md; do + [ "$FILE" = .changeset/README.md ] && continue + awk '/^---[[:space:]]*$/ { n++; next } n == 1 && !/^[[:space:]]*(#.*)?$/ { found = 1 } END { exit !found }' "$FILE" \ + && PENDING+="$FILE"$'\n' + done + if [ -n "$PENDING" ]; then + echo "::warning::main has unreleased changes that are not part of $BRANCH; cherry-pick them including their changesets if $MAJOR.x.y needs them:" + echo -n "$PENDING" + echo -n "$PENDING" > "$RUNNER_TEMP/pending-changesets.txt" + fi + fi + + TAG=$(git tag --list "$MAJOR.*" | grep -E "^$MAJOR\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1 || true) + [ -n "$TAG" ] || fail "No release $MAJOR.x.y found." + + # Releases made with the old release process have neither Changesets nor these + # workflows, so a branch cut from them could not release. + git cat-file -e "$TAG:.github/workflows/create-maintenance-branch.yml" 2> /dev/null \ + || fail "Release $TAG predates the Changesets-based maintenance support; cut the branch manually or release $MAJOR.x.y from main first." + + echo "Creating $BRANCH from $TAG (main is on major $MAIN_MAJOR)" + { + echo "branch=$BRANCH" + echo "tag=$TAG" + echo "main-major=$MAIN_MAJOR" + } >> "$GITHUB_OUTPUT" + + - name: Create and push branch + env: + BRANCH: ${{ steps.validate.outputs.branch }} + TAG: ${{ steps.validate.outputs.tag }} + run: | + git switch -c "$BRANCH" "$TAG" + + # Changesets compares against its base branch, e.g. in "changeset status". + jq --indent 2 --arg branch "$BRANCH" '.baseBranch = $branch' .changeset/config.json \ + > "$RUNNER_TEMP/config.json" + mv "$RUNNER_TEMP/config.json" .changeset/config.json + + git add .changeset/config.json + git commit -m "ci: Create $BRANCH from $TAG" + git push origin "$BRANCH" + + - name: Summary + env: + BRANCH: ${{ steps.validate.outputs.branch }} + TAG: ${{ steps.validate.outputs.tag }} + MAJOR: ${{ inputs.major }} + MAIN_MAJOR: ${{ steps.validate.outputs.main-major }} + run: | + { + echo "## ✅ Created [$BRANCH](${{ github.server_url }}/${{ github.repository }}/tree/$BRANCH) from $TAG" + echo "" + echo "- Open pull requests against \`$BRANCH\`; they need a \`patch\` or \`minor\` changeset." + echo "- Releases are published with the npm dist-tag \`maintenance-$MAJOR\` and do not become \`latest\`." + if [ "$MAIN_MAJOR" = "$MAJOR" ]; then + echo "- main is still on major $MAJOR: its next release must be major. Its \"Version Packages\" pull request fails until a \`major\` changeset is pending on main." + fi + if [ -s "$RUNNER_TEMP/pending-changesets.txt" ]; then + echo "- ⚠️ main has unreleased changes that are not part of $BRANCH. Cherry-pick them, including their changesets, if $MAJOR.x.y needs them:" + sed 's/.*/ - `&`/' "$RUNNER_TEMP/pending-changesets.txt" + fi + echo "- Dependabot only updates main: add an entry with \`target-branch: $BRANCH\` to \`.github/dependabot.yml\` on main if this line should get action updates." + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/create-or-update-release-pr.yml b/.github/workflows/create-or-update-release-pr.yml index e63f3f9fcf..eb670dd012 100644 --- a/.github/workflows/create-or-update-release-pr.yml +++ b/.github/workflows/create-or-update-release-pr.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - 'maintenance/*' permissions: contents: write @@ -44,5 +45,8 @@ jobs: uses: changesets/action@8488615a623b1b9c987934bb89eae8af6a946ac1 # v2.1.1 with: version-script: pnpm ci:version - pr-base-branch: main + # One "Version Packages" PR per release line (branch changeset-release/). + pr-base-branch: ${{ github.ref_name }} + pr-title: Version Packages (${{ github.ref_name }}) + commit-message: Version Packages (${{ github.ref_name }}) github-token: ${{ secrets.GH_PAT_PUSH_FROM_GHA }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2dbcc58a87..62bf945a63 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -49,7 +49,9 @@ jobs: uses: ./.github/actions/checks with: perform-all-checks: 'true' - base-ref: origin/main + # Manual runs have no base to compare against, so they skip the changeset check. + base-ref: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || '' }} + target-branch: ${{ github.base_ref || github.ref_name }} fork: name: Fork Pull Request diff --git a/.github/workflows/qa-gate.yml b/.github/workflows/qa-gate.yml index 896fdd9178..332161adc2 100644 --- a/.github/workflows/qa-gate.yml +++ b/.github/workflows/qa-gate.yml @@ -5,13 +5,20 @@ on: types: [labeled, unlabeled] branches: - main + # Release lines created by create-maintenance-branch.yml. The legacy maintenance/.0 + # branches do not run this: pull_request_target uses the base branch's workflow files. + - 'maintenance/*' permissions: contents: write pull-requests: write +env: + # Every release line has its own queue: main or maintenance/. + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} + concurrency: - group: qa-gate-main + group: qa-gate-${{ github.event.pull_request.base.ref }} cancel-in-progress: false run-name: | @@ -37,10 +44,10 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - # Get all open PRs into main with 'approved' label but without 'qa-failed', sorted by updated_at (oldest first) + # Get all open PRs into the base branch with 'approved' label but without 'qa-failed', sorted by updated_at (oldest first) OLDEST_PR=$(gh api \ -H "Accept: application/vnd.github+json" \ - "/repos/${{ github.repository }}/pulls?state=open&base=main&sort=updated&direction=asc" \ + "/repos/${{ github.repository }}/pulls?state=open&base=${BASE_BRANCH}&sort=updated&direction=asc" \ --jq '[.[] | select((.labels | map(.name) | contains(["approved"])) and (.labels | map(.name) | contains(["qa-failed"]) | not))] | first | .number') CURRENT_PR=${{ github.event.pull_request.number }} @@ -79,10 +86,10 @@ jobs: needs: check-queue if: needs.check-queue.outputs.should-proceed == 'true' steps: - - name: Checkout main + - name: Checkout base branch uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: main + ref: ${{ env.BASE_BRANCH }} fetch-depth: 0 token: ${{ secrets.GH_PAT_PUSH_FROM_GHA }} @@ -104,10 +111,10 @@ jobs: # targets (git rebase -i --autosquash) before the PR can be integrated. MARKER_COMMITS=$(git log --no-merges -E \ --grep='^(fixup|squash|amend)! ' \ - --format='%h %s' "main..origin/$PR_BRANCH" || true) + --format='%h %s' "${BASE_BRANCH}..origin/$PR_BRANCH" || true) if [ -n "$MARKER_COMMITS" ]; then - echo "::error::The PR contains fixup!/squash!/amend! commits. Run 'git rebase -i --autosquash main' and push before integration." + echo "::error::The PR contains fixup!/squash!/amend! commits. Run 'git rebase -i --autosquash ${BASE_BRANCH}' and push before integration." { echo "## ❌ Autosquash commits found" echo "" @@ -122,7 +129,7 @@ jobs: echo "No fixup/squash commits found." - - name: Merge PR branch into main + - name: Merge PR branch into base branch env: PR_BRANCH: ${{ needs.check-queue.outputs.pr-branch }} PR_NUMBER: ${{ needs.check-queue.outputs.pr-number }} @@ -130,7 +137,7 @@ jobs: echo "Fetching PR branch: $PR_BRANCH" git fetch origin "$PR_BRANCH" - echo "Merging $PR_BRANCH into main" + echo "Merging $PR_BRANCH into $BASE_BRANCH" if ! git merge "origin/$PR_BRANCH" --no-edit -m "Merge PR #$PR_NUMBER"; then echo "::error::Merge conflict detected. Please rebase your branch." exit 1 @@ -148,25 +155,26 @@ jobs: - name: Checks uses: ./.github/actions/checks with: - base-ref: origin/main + base-ref: origin/${{ env.BASE_BRANCH }} + target-branch: ${{ env.BASE_BRANCH }} - - name: Push to main + - name: Push to base branch env: PR_NUMBER: ${{ needs.check-queue.outputs.pr-number }} run: | - echo "Pushing to main..." - git push origin main + echo "Pushing to $BASE_BRANCH..." + git push origin "$BASE_BRANCH" # Update local tracking to match remote after push - git fetch origin main - git branch --set-upstream-to=origin/main main + git fetch origin "$BASE_BRANCH" + git branch --set-upstream-to="origin/$BASE_BRANCH" "$BASE_BRANCH" - echo "## ✅ PR #$PR_NUMBER successfully integrated" >> $GITHUB_STEP_SUMMARY + echo "## ✅ PR #$PR_NUMBER successfully integrated into $BASE_BRANCH" >> $GITHUB_STEP_SUMMARY - - name: Deploy Storybook for main + - name: Deploy Storybook for base branch uses: ./.github/actions/deploy-storybook with: - branch-name: main + branch-name: ${{ env.BASE_BRANCH }} ckeditor-license: ${{ secrets.CKEDITOR_LICENSE }} on-failure: diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 327f0444ed..8c926d6666 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -6,6 +6,7 @@ on: push: branches: - main + - 'maintenance/*' permissions: contents: write @@ -34,10 +35,15 @@ jobs: # "changeset version" consumed them are the packages ready to be published. COUNT=$(find .changeset -maxdepth 1 -name '*.md' ! -name 'README.md' | wc -l) echo "Pending changesets: $COUNT" - if [ "$COUNT" -eq 0 ]; then - echo "should-release=true" >> $GITHUB_OUTPUT - else + VERSION=$(jq -r .version packages/ckeditor5-common/package.json) + if [ "$COUNT" -ne 0 ]; then echo "should-release=false" >> $GITHUB_OUTPUT + # Nothing to publish without a new version, e.g. when maintenance/ is created. + elif git ls-remote --exit-code --tags origin "refs/tags/$VERSION" > /dev/null; then + echo "$VERSION is already released." + echo "should-release=false" >> $GITHUB_OUTPUT + else + echo "should-release=true" >> $GITHUB_OUTPUT fi release: @@ -69,6 +75,21 @@ jobs: - name: Checks uses: ./.github/actions/checks + with: + target-branch: ${{ github.ref_name }} + + # Releases from a maintenance branch must not become "latest": consumers of the + # newest major get it from main. + - name: Determine release line + id: line + run: | + if [[ "$GITHUB_REF_NAME" == maintenance/* ]]; then + echo "dist-tag=maintenance-${GITHUB_REF_NAME#maintenance/}" >> "$GITHUB_OUTPUT" + echo "latest=false" >> "$GITHUB_OUTPUT" + else + echo "dist-tag=" >> "$GITHUB_OUTPUT" + echo "latest=true" >> "$GITHUB_OUTPUT" + fi - name: Setup npm registries for publish run: | @@ -83,7 +104,7 @@ jobs: id: changesets uses: changesets/action@8488615a623b1b9c987934bb89eae8af6a946ac1 # v2.1.1 with: - publish-script: pnpm ci:publish + publish-script: ${{ steps.line.outputs.dist-tag && format('pnpm ci:publish --tag {0}', steps.line.outputs.dist-tag) || 'pnpm ci:publish' }} github-token: ${{ github.token }} # One aggregate release per version instead of one per package (see below). create-github-releases: false @@ -108,16 +129,18 @@ jobs: node scripts/release-notes.mjs "$VERSION" > "$RUNNER_TEMP/release-notes.md" git tag -a "$VERSION" -m "$VERSION" git push origin "$VERSION" - gh release create "$VERSION" --verify-tag --title "v$VERSION" --notes-file "$RUNNER_TEMP/release-notes.md" + gh release create "$VERSION" --verify-tag --title "v$VERSION" --notes-file "$RUNNER_TEMP/release-notes.md" \ + --latest=${{ steps.line.outputs.latest }} echo "## Released $VERSION" >> "$GITHUB_STEP_SUMMARY" # Separate job, so a manual run deploys the documentation even while changesets are # pending and the release job is skipped (e.g. to initially fill gh-pages). + # GitHub Pages documents main only. docs: name: Deploy documentation needs: [check-changesets, release] if: >- - !cancelled() && needs.release.result != 'failure' && + !cancelled() && needs.release.result != 'failure' && github.ref_name == 'main' && (needs.release.outputs.published == 'true' || github.event_name == 'workflow_dispatch') runs-on: ubuntu-latest timeout-minutes: 20 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index b3070004b1..ec025b7cf7 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -37,6 +37,18 @@ jobs: echo "Calculated snapshot version: ${next_version}" echo "version=${next_version}" >> $GITHUB_OUTPUT + # Snapshots of an older major than main (a maintenance branch or a branch based on + # one) get their own dist-tag. All snapshots of main's major share "snapshot", also + # those of a maintenance branch created while main is still on that major. + main_major=$(git show origin/main:packages/ckeditor5-common/package.json | jq -r .version | cut -d. -f1) + if [ "$major" = "$main_major" ]; then + dist_tag=snapshot + else + dist_tag="snapshot-maintenance-${major}" + fi + echo "Dist-tag: ${dist_tag}" + echo "dist-tag=${dist_tag}" >> $GITHUB_OUTPUT + - name: Build uses: ./.github/actions/build with: @@ -49,6 +61,7 @@ jobs: env: NEXUS_USER: ${{ secrets.PLUGINS_NEXUS_USER }} NEXUS_PASSWORD: ${{ secrets.PLUGINS_NEXUS_PASSWORD }} + DIST_TAG: ${{ steps.version.outputs.dist-tag }} run: | TARGET_REGISTRY="https://repository.coremedia.com/nexus/repository/npm-github-hosted/" @@ -70,7 +83,7 @@ jobs: echo "Publishing packages to $TARGET_REGISTRY" # Publish all packages directly - pnpm -r publish --tag snapshot --no-git-checks + pnpm -r publish --tag "$DIST_TAG" --no-git-checks mv "$GITHUB_WORKSPACE/.npmrc.bak" "$GITHUB_WORKSPACE/.npmrc" @@ -84,6 +97,7 @@ jobs: echo "## ✅ Snapshot published" >> $GITHUB_STEP_SUMMARY echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY echo "**Registry:** npm-github-hosted" >> $GITHUB_STEP_SUMMARY + echo "**Dist-tag:** ${DIST_TAG}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "### pnpm-workspace.yaml catalog entries" >> $GITHUB_STEP_SUMMARY echo "Add the following to your \`pnpm-workspace.yaml\` under \`catalog:\`:" >> $GITHUB_STEP_SUMMARY diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 8a889ab0ff..0d6e58a32f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -45,6 +45,57 @@ pnpm changeset add --empty All published packages share one version: a changeset for one package bumps all of them. +## Maintenance Branches + +`main` holds the newest major. To ship fixes for an older major (see +[Versioning](./VERSIONING.md)), create a maintenance branch `maintenance/` +with the GitHub Actions workflow _Create Maintenance Branch_ (input: the major, +e.g. `30`). It creates the branch from the newest release of that major. + +A maintenance branch is a release line of its own and works like `main`: pull +requests need a changeset, are integrated by the QA gate, and are released via a +"Version Packages" pull request. Differences: + +* Only `patch` and `minor` changesets are allowed; `major` changesets are rejected. +* Releases are published with the npm dist-tag `maintenance-`, so `latest` + keeps pointing to the newest release from `main`. Their GitHub release is not + marked as latest. +* The API documentation on GitHub Pages is only deployed from `main`. + +A fix needed on both lines is made on one branch and cherry-picked to the other, +including its changeset. `main` and maintenance branches are never merged into each +other. + +A maintenance branch keeps the GitHub Actions workflows of the release it was +created from. Fixes of the workflows on `main` do not reach it: cherry-pick them if +the branch needs them. Likewise, Dependabot only updates `main`; add an entry with +`target-branch: maintenance/` to `.github/dependabot.yml` on `main` if a +branch should get action updates. + +**Example:** + +1. `main` is released up to `30.4.2`; a CMCC version is bound to major 30. +2. `main` moves on with breaking changes and releases `31.0.0`, `31.1.0` and + `32.0.0`. +3. A customer on that CMCC version needs a security fix, still on major 30. +4. _Create Maintenance Branch_ with `30` creates `maintenance/30` from `30.4.2`. +5. The fix is cherry-picked into `maintenance/30` with a `patch` changeset and + released as `30.4.3` (dist-tag `maintenance-30`); `latest` stays on `32.x`. + +The branch may also be created while `main` is still on that major, e.g. right +before breaking changes, as long as `main` has no unreleased version (e.g. after a +failed release). Changes merged into `main` with changesets that are not released +yet are not part of the branch: release them first or cherry-pick them; the +workflow lists them. `main` must then not release that major again: its +"Version Packages" pull request and its release fail until a `major` changeset is +pending, and pull requests into `main` get a warning until then. + +The branch can only be created from a release that already contains the workflow +_Create Maintenance Branch_, i.e. a release made with Changesets after it was +introduced. Releases of the old release process (up to `28.1.1`) and the legacy +branches `maintenance/23.0`, `24.0` and `25.0` are not supported by this workflow. +Major 28 becomes maintainable with its first release made with Changesets. + ## Update Process All dependency versions are maintained centrally in the `catalog` of diff --git a/package.json b/package.json index c99bb8aab9..9ffb38587d 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ }, "devDependencies": { "@changesets/cli": "catalog:", + "@changesets/read": "catalog:", "@coremedia/studio-client.eslint-config": "catalog:", "eslint": "catalog:", "rimraf": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0afbe0b2ab..053d9e335b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,9 @@ catalogs: '@changesets/cli': specifier: ^3.0.3 version: 3.0.3 + '@changesets/read': + specifier: ^1.0.1 + version: 1.0.1 '@ckeditor/ckeditor5-inspector': specifier: ^5.0.3 version: 5.0.3 @@ -171,6 +174,9 @@ importers: '@changesets/cli': specifier: 'catalog:' version: 3.0.3 + '@changesets/read': + specifier: 'catalog:' + version: 1.0.1 '@coremedia/studio-client.eslint-config': specifier: 'catalog:' version: 2.0.0(@types/eslint@9.6.1)(@typescript-eslint/utils@8.67.0(eslint@10.9.1(jiti@1.21.6)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3))(eslint-import-resolver-node@0.3.9(supports-color@8.1.1))(eslint@10.9.1(jiti@1.21.6)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8244719221..43fbdde596 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -15,6 +15,7 @@ catalog: '@bbob/preset-html5': 4.3.1 '@bbob/types': 4.3.1 '@changesets/cli': ^3.0.3 + '@changesets/read': ^1.0.1 '@ckeditor/ckeditor5-inspector': ^5.0.3 '@coremedia-internal/studio-client.playwright-config': ^1.4.0 '@coremedia-internal/studio-client.storybook-config': ^2.0.1 diff --git a/scripts/major-changesets.mjs b/scripts/major-changesets.mjs new file mode 100644 index 0000000000..f0d40bdc01 --- /dev/null +++ b/scripts/major-changesets.mjs @@ -0,0 +1,20 @@ +#!/usr/bin/env node +/** + * Prints the pending changesets that request a major bump, one per line, as paths + * relative to the repository root. + * + * Changesets are read by Changesets itself, so every valid frontmatter is recognized + * (quotes, comments, …) and an unparsable changeset fails. + * + * Usage: node scripts/major-changesets.mjs + */ +import path from "node:path"; +import { readChangesets } from "@changesets/read"; + +const rootDir = path.join(import.meta.dirname, ".."); + +for (const { id, releases } of await readChangesets(rootDir)) { + if (releases.some(({ type }) => type === "major")) { + console.log(`.changeset/${id}.md`); + } +}