diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml deleted file mode 100644 index 386e92f46e..0000000000 --- a/.github/workflows/sync-upstream.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: sync-upstream - -on: - schedule: - - cron: "0 6 * * 1" # Mondays 06:00 UTC - workflow_dispatch: - inputs: - ref: - description: "Upstream branch or tag to merge" - default: "dev" - required: false - -permissions: - contents: write - pull-requests: write - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: main - fetch-depth: 0 - - - name: Fetch upstream - run: | - git remote add upstream https://github.com/anomalyco/opencode.git - git fetch upstream --tags - - - name: Merge upstream - id: merge - run: | - REF="${{ github.event.inputs.ref || 'dev' }}" - TARGET=$(git rev-parse --verify --quiet "refs/remotes/upstream/$REF" || git rev-parse --verify "refs/tags/$REF^{commit}") - if git merge-base --is-ancestor "$TARGET" HEAD; then - echo "Already up to date with upstream/$REF ($TARGET)." - echo "status=uptodate" >> "$GITHUB_OUTPUT" - exit 0 - fi - git config user.name "codev-sync" - git config user.email "github-actions[bot]@users.noreply.github.com" - BRANCH="sync-upstream-$(date +%Y%m%d)" - git checkout -b "$BRANCH" - if git merge --no-edit -m "chore: merge upstream $REF ($(git rev-parse --short "$TARGET"))" "$TARGET"; then - git push -u origin "$BRANCH" - echo "status=merged" >> "$GITHUB_OUTPUT" - echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" - echo "target=$TARGET" >> "$GITHUB_OUTPUT" - echo "ref=$REF" >> "$GITHUB_OUTPUT" - else - echo "::error::Merge of upstream/$REF has conflicts. Resolve locally (see DIVERGENCES.md):" - git diff --name-only --diff-filter=U | sed 's/^/::error:: conflict: /' - exit 1 - fi - - - name: Open pull request - if: steps.merge.outputs.status == 'merged' - env: - GH_TOKEN: ${{ github.token }} - run: | - gh pr create \ - --base main \ - --head "${{ steps.merge.outputs.branch }}" \ - --title "chore: merge upstream ${{ steps.merge.outputs.ref }}" \ - --body "Automated merge of [upstream \`${{ steps.merge.outputs.ref }}\`](https://github.com/anomalyco/opencode/tree/${{ steps.merge.outputs.ref }}) at \`${{ steps.merge.outputs.target }}\`. - - Review checklist: - - [ ] CI green (typecheck, tests) - - [ ] Divergences intact (see DIVERGENCES.md) - - [ ] \`bun.lock\` / generated files regenerated, not hand-merged" diff --git a/DIVERGENCES.md b/DIVERGENCES.md index 1a18832a70..257ff3213c 100644 --- a/DIVERGENCES.md +++ b/DIVERGENCES.md @@ -1,11 +1,12 @@ # Divergences from upstream -Every deliberate change to an upstream file is listed here. When a `sync-upstream` merge -conflicts, this table tells you what the conflict is about and how to resolve it. If you -edit an upstream file and it is not in this table, add it — an unlisted divergence is a bug. +Every deliberate change to an upstream file is listed here. When an upstream sync patch +(see README → Syncing with upstream) conflicts, this table tells you what the conflict is +about and how to resolve it. If you edit an upstream file and it is not in this table, +add it — an unlisted divergence is a bug. -New files that upstream does not have (this file, `NOTICE`, `.github/workflows/sync-upstream.yml`, -future `packages/codev-*`) never conflict and are not tracked here. +New files that upstream does not have (this file, `NOTICE`, future `packages/codev-*`) +never conflict and are not tracked here. ## Changed upstream files diff --git a/README.md b/README.md index 540b484ba0..f6219beaa0 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,27 @@ Notes: ## Syncing with upstream -A scheduled GitHub Action ([`sync-upstream.yml`](.github/workflows/sync-upstream.yml)) merges upstream `dev` into `main` weekly and opens a PR. It can also be run on demand (Actions → sync-upstream → Run workflow) against any upstream branch or tag. - -One-time repo setup for the action to open PRs: **Settings → Actions → General → Allow GitHub Actions to create and approve pull requests**. - -Manual sync: +Syncing is manual and local — there is no CI workflow. `main` carries fork commits only +(history was truncated; it shares no ancestry with upstream), so `git merge upstream/...` +does not work. Instead, apply upstream's changes as a 3-way patch between release tags. +The tag the fork is currently on is the `version` in `packages/opencode/package.json`. ```sh -git fetch upstream --tags +git fetch upstream --tags # also brings in the blobs `git apply -3` needs git checkout -b sync-upstream main -git merge upstream/dev +# FROM = current version in packages/opencode/package.json; TO = target release +git diff v v --binary -- . ':(exclude)bun.lock' | git apply -3 --index # Conflicts in our own files: see DIVERGENCES.md for each file's resolution strategy. -# Conflicts in bun.lock or generated code: regenerate (bun install / bun run generate), never hand-merge. +# Files we deleted (locales, README translations): if the patch re-adds them, delete them again. +bun install # regenerate bun.lock, never patch it +bun turbo typecheck +git commit -m "chore: sync upstream v" ``` +`git apply -3` leaves ordinary conflict markers where our divergences overlap upstream +changes — the same conflict surface the old merge had. If a hunk fails outright, it is +usually against a file we deleted or renamed; check DIVERGENCES.md before forcing it. + ## Divergence policy Features go, in order of preference: