diff --git a/.github/workflows/apps-web-check.yml b/.github/workflows/apps-web-check.yml index 749776dbe23..16ee73593e6 100644 --- a/.github/workflows/apps-web-check.yml +++ b/.github/workflows/apps-web-check.yml @@ -2,9 +2,9 @@ name: apps/web check on: pull_request: - branches: [main, develop, "3.1.x", "3.0.x"] + branches: [main, develop, "3.2.x", "3.1.x", "3.0.x"] push: - branches: [main, develop, "3.1.x", "3.0.x"] + branches: [main, develop, "3.2.x", "3.1.x", "3.0.x"] permissions: contents: read diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index d17804def80..4d39c6decd3 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -2,9 +2,9 @@ name: Build Check on: pull_request: - branches: [main, develop, "3.1.x", "3.0.x"] + branches: [main, develop, "3.2.x", "3.1.x", "3.0.x"] push: - branches: [main, develop, "3.1.x", "3.0.x"] + branches: [main, develop, "3.2.x", "3.1.x", "3.0.x"] concurrency: group: build-check-${{ github.ref }} diff --git a/.github/workflows/changeset-check.yml b/.github/workflows/changeset-check.yml index f74bdd5d10a..b64eb64c875 100644 --- a/.github/workflows/changeset-check.yml +++ b/.github/workflows/changeset-check.yml @@ -2,7 +2,7 @@ name: Changeset Check on: pull_request: - branches: [main, '3.1.x', '3.0.x'] + branches: [main, '3.2.x', '3.1.x', '3.0.x'] jobs: pr-title: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cb1c90df84d..382791d4ef6 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: CodeQL on: push: - branches: [main, '3.1.x', '3.0.x'] + branches: [main, '3.2.x', '3.1.x', '3.0.x'] pull_request: - branches: [main, '3.1.x', '3.0.x'] + branches: [main, '3.2.x', '3.1.x', '3.0.x'] schedule: - cron: "0 0 * * 0" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index d84ebc12240..e1d5ddfd1bc 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -2,7 +2,7 @@ name: Dependency Review on: pull_request: - branches: [main, develop, '3.1.x', '3.0.x'] + branches: [main, develop, '3.2.x', '3.1.x', '3.0.x'] permissions: contents: read diff --git a/.github/workflows/forward-merge-3.2.yml b/.github/workflows/forward-merge-3.2.yml new file mode 100644 index 00000000000..fb142414307 --- /dev/null +++ b/.github/workflows/forward-merge-3.2.yml @@ -0,0 +1,239 @@ +name: Forward-merge 3.2.x to main + +# Brings 3.2.x patches back into main so the next minor continues to include +# all 3.2.x fixes. Direction is one-way: 3.2.x → main. Never the reverse. +# +# On every push to 3.2.x (typically a Version Packages merge or a +# cherry-picked patch), this workflow merges 3.2.x into a fresh branch +# off main and opens a PR. A human reviews and merges. If the merge has +# conflicts, the workflow fails fast and the PR is not opened — a human +# must resolve manually. +# +# The PR is opened with a GitHub App installation token (RELEASE_APP_ID), +# so its open/sync events fire required `pull_request` workflows +# (TypeScript Build, IPR Policy, Check for changeset). #3417 closed. + +on: + push: + branches: + - '3.2.x' + workflow_dispatch: + +concurrency: + group: forward-merge-3.2 + cancel-in-progress: false + +permissions: + contents: write + pull-requests: write + +jobs: + forward-merge: + name: Forward-merge 3.2.x → main + runs-on: ubuntu-latest + steps: + # Mint a GitHub App installation token so the auto-opened PR fires + # required CI workflows (TypeScript Build, IPR Policy, Check for + # changeset). GITHUB_TOKEN-triggered events are blocked by GitHub's + # recursion rule. Closes #3417. + - name: Mint AgenticAdvertising.org Release Bot installation token + id: app-token + uses: actions/create-github-app-token@v3.2.0 + with: + app-id: ${{ secrets.RELEASE_APP_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + owner: adcontextprotocol + repositories: adcp + + - name: Checkout main with full history + uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + ref: main + token: ${{ steps.app-token.outputs.token }} + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Fetch 3.2.x + run: git fetch origin 3.2.x + + - name: Create forward-merge branch and merge + id: merge + run: | + set -e + git checkout -B forward-merge/3.2.x origin/main + + MERGE_MSG="Forward-merge 3.2.x@$(git rev-parse --short origin/3.2.x) → main" + if git merge --no-ff origin/3.2.x -m "$MERGE_MSG"; then + echo "Merge completed without conflicts." + else + CONFLICTS=$(git diff --name-only --diff-filter=U) + if [ -z "$CONFLICTS" ]; then + echo "::error::git merge failed but produced no conflicted files. Investigate manually." + git merge --abort 2>/dev/null || true + exit 1 + fi + echo "Conflicts to auto-resolve:" + echo "$CONFLICTS" + + UNEXPECTED="" + while IFS= read -r f; do + [ -z "$f" ] && continue + case "$f" in + # `.changeset/*.md` and `.changeset/pre.json`: preserve main's + # state. Main consumes changesets on its own schedule; 3.2.x + # consuming a changeset on its release line shouldn't delete + # the same file from main's pending pool. + .changeset/*.md|.changeset/pre.json) + STATUS=$(git status --porcelain -- "$f" | head -c 2) + case "$STATUS" in + DU|DD|D*) + git rm -f -- "$f" >/dev/null + ;; + *) + git checkout --ours -- "$f" + git add -- "$f" + ;; + esac + ;; + # package.json / package-lock.json: keep main's. + # Main may carry structural changes (package renames, new deps) + # that 3.2.x doesn't. Main's version state is set by its own + # changeset schedule, not by 3.2.x's patch bumps. + package.json|package-lock.json) + git checkout --ours -- "$f" + git add -- "$f" + ;; + # Schema source index files carry branch-local version + # metadata. Preserve main's copy. + static/schemas/source/index.json|static/schemas/source/registry/index.yaml) + git checkout --ours -- "$f" + git add -- "$f" + ;; + # CHANGELOG.md: take 3.2.x's (canonical patch-line history); + # main's next Version Packages cut prepends its own entries. + CHANGELOG.md) + git checkout --theirs -- "$f" + git add -- "$f" + ;; + # dist/ release artifacts: always take 3.2.x's. These are + # immutable per release; main only ever ADDS to its dist tree. + dist/schemas/*|dist/compliance/*|dist/protocol/*|dist/docs/*) + git checkout --theirs -- "$f" + git add -- "$f" + ;; + *) + UNEXPECTED="$UNEXPECTED $f" + ;; + esac + done <<< "$CONFLICTS" + + if [ -n "$UNEXPECTED" ]; then + echo "::error::Forward-merge has content conflicts that require human review:$UNEXPECTED" + echo "::error::Each conflict is a real decision about whether 3.2.x's change should land on main." + echo "::error::Resolve manually:" + echo "::error:: git fetch origin && git checkout -b forward-merge/3.2.x origin/main" + echo "::error:: git merge origin/3.2.x # resolve conflicts in editor" + echo "::error:: git push origin forward-merge/3.2.x" + echo "::error:: gh pr create --base main --head forward-merge/3.2.x" + git merge --abort + exit 1 + fi + + REMAINING=$(git diff --name-only --diff-filter=U) + if [ -n "$REMAINING" ]; then + echo "::error::After auto-resolution, files still conflicted: $REMAINING" + git merge --abort + exit 1 + fi + + git commit --no-edit -m "$MERGE_MSG (auto-resolved divergent metadata)" + echo "Auto-resolution complete." + + echo "" + echo "::group::Post-resolution git status" + git status --short + echo "::endgroup::" + echo "" + echo "::group::package.json diff vs origin/main" + git diff origin/main HEAD -- package.json package-lock.json || true + echo "::endgroup::" + fi + + if git diff --quiet origin/main HEAD; then + echo "Forward-merge produced no tree change — main already has 3.2.x's content." + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + git push --force origin "HEAD:refs/heads/forward-merge/3.2.x" + fi + + - name: Create or update pull request + if: steps.merge.outputs.skip != 'true' + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + PR_HEAD: forward-merge/3.2.x + PR_TITLE: "Forward-merge 3.2.x → main" + run: | + set -euo pipefail + + EXISTING_PR="$(gh pr list \ + --repo "$GITHUB_REPOSITORY" \ + --state open \ + --base main \ + --head "$PR_HEAD" \ + --limit 1 \ + --json url \ + --jq '.[0].url // empty')" + + if [ -n "$EXISTING_PR" ]; then + echo "Forward-merge PR already open: $EXISTING_PR" + exit 0 + fi + + BODY_FILE="$RUNNER_TEMP/forward-merge-3.2.md" + cat > "$BODY_FILE" <<'EOF' + Auto-generated forward-merge of `3.2.x` into `main`. + + Brings 3.2.x patches into main so the next minor continues to include + all 3.2.x fixes. **Direction is one-way**: `3.2.x → main`. Never the + reverse. + + ## Auto-resolved divergent metadata + + Conflicts on these always-divergent paths are resolved automatically: + + - `package.json` / `package-lock.json` → preserve main's + - `.changeset/*.md` / `.changeset/pre.json` → preserve main's state + - `static/schemas/source/index.json`, + `static/schemas/source/registry/index.yaml` → preserve main's + - `CHANGELOG.md` → take 3.2.x's + - `dist/*` → take 3.2.x's (versioned release artifacts) + + Any conflict outside this list fails the workflow loud. + + ## Review checklist + + - [ ] Diff matches what you'd expect from the 3.2.x patches + - [ ] No next-minor work has been pulled in by accident + - [ ] CI green + + ## Source + + See `.github/workflows/forward-merge-3.2.yml` for the trigger + and auto-resolution logic. See `.agents/playbook.md` § Release + lines for the cherry-pick convention. + + 🤖 Generated by `.github/workflows/forward-merge-3.2.yml` + EOF + + gh pr create \ + --repo "$GITHUB_REPOSITORY" \ + --base main \ + --head "$PR_HEAD" \ + --title "$PR_TITLE" \ + --body-file "$BODY_FILE" \ + --label forward-merge diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 069f8519e65..97e8331be25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - '3.2.x' - '3.1.x' - '3.0.x' workflow_dispatch: @@ -65,7 +66,7 @@ jobs: if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then case "${GITHUB_REF_NAME}" in - main|3.1.x|3.0.x) ;; + main|3.2.x|3.1.x|3.0.x) ;; *) echo "::error::Release recovery must run from a supported release branch." exit 1 @@ -141,7 +142,7 @@ jobs: PUPPETEER_SKIP_DOWNLOAD: 'true' - name: Verify current storyboard coverage - if: steps.release-relevance.outputs.relevant == 'true' && (github.ref_name == 'main' || github.ref_name == '3.1.x') + if: steps.release-relevance.outputs.relevant == 'true' && (github.ref_name == 'main' || github.ref_name == '3.2.x' || github.ref_name == '3.1.x') run: npm run test:storyboards env: # A committed Version Packages bundle can lead the training agent's @@ -150,7 +151,7 @@ jobs: ADCP_STORYBOARD_CANDIDATE_VERSION_MODE: '1' - name: Verify 3.0 storyboard compatibility - if: steps.release-relevance.outputs.relevant == 'true' && (github.ref_name == 'main' || github.ref_name == '3.1.x' || github.ref_name == '3.0.x') + if: steps.release-relevance.outputs.relevant == 'true' && (github.ref_name == 'main' || github.ref_name == '3.2.x' || github.ref_name == '3.1.x' || github.ref_name == '3.0.x') run: npm run test:storyboards:3.0-compat env: ADCP_RELEASE_BASE_REF: 3.0.x diff --git a/scripts/check-release-state.cjs b/scripts/check-release-state.cjs index a8cb8a0c50c..e7f72fc776f 100644 --- a/scripts/check-release-state.cjs +++ b/scripts/check-release-state.cjs @@ -18,7 +18,7 @@ function current() { const branch = process.env.PUBLICATION_BRANCH || process.env.GITHUB_REF_NAME; if ( !shaPattern.test(expected || "") || - !["main", "3.1.x", "3.0.x"].includes(branch) + !["main", "3.2.x", "3.1.x", "3.0.x"].includes(branch) ) { throw new Error( "Publication requires an exact tested SHA and a supported release branch.", diff --git a/scripts/fence-changesets.cjs b/scripts/fence-changesets.cjs index def048810f6..223cd9d10d6 100644 --- a/scripts/fence-changesets.cjs +++ b/scripts/fence-changesets.cjs @@ -224,7 +224,7 @@ function prepare() { const branch = process.env.PUBLICATION_BRANCH; const repository = process.env.GITHUB_REPOSITORY; if ( - !["main", "3.1.x", "3.0.x"].includes(branch) || + !["main", "3.2.x", "3.1.x", "3.0.x"].includes(branch) || !sha(process.env.TESTED_SHA) || !/^[\w.-]+\/[\w.-]+$/.test(repository || "") ) diff --git a/tests/release-workflow-immutability.test.cjs b/tests/release-workflow-immutability.test.cjs index efffaa9f7f1..ccbd0be4d9c 100644 --- a/tests/release-workflow-immutability.test.cjs +++ b/tests/release-workflow-immutability.test.cjs @@ -37,7 +37,7 @@ const activeWorkflowPaths = [ 'check-testable-snippets.yml', 'release.yml', ]; -const forwardMergeWorkflows = ['3.0', '3.1'].map((line) => ({ +const forwardMergeWorkflows = ['3.0', '3.1', '3.2'].map((line) => ({ line, source: fs.readFileSync( path.join(repoRoot, `.github/workflows/forward-merge-${line}.yml`), @@ -229,7 +229,7 @@ assert.strictEqual( assert( releaseTarget.includes('^[0-9a-f]{40}$') && releaseTarget.includes('git merge-base --is-ancestor "${target_commit}" "refs/remotes/origin/${GITHUB_REF_NAME}"') && - releaseTarget.includes('main|3.1.x|3.0.x'), + releaseTarget.includes('main|3.2.x|3.1.x|3.0.x'), 'Manual recovery must require a full SHA already reachable from a supported release branch.' );