Repository navigation
Sync OpenCode spec #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync OpenCode spec | |
| on: | |
| schedule: | |
| - cron: "17 6 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "@opencode/protocol version (defaults to latest)" | |
| required: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| generate: | |
| # Runs third-party npm code, so it has a read-only token and no stored credentials. | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 | |
| - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 | |
| - name: Resolve version | |
| id: version | |
| env: | |
| REQUESTED: ${{ inputs.version }} | |
| run: | | |
| version="${REQUESTED:-$(npm view @opencode/protocol version)}" | |
| if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "Invalid version: $version"; exit 1; fi | |
| effect=$(npm view "@opencode/protocol@$version" dependencies.effect) | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "effect=$effect" >> "$GITHUB_OUTPUT" | |
| - name: Extract contract | |
| working-directory: codegen/extract | |
| run: | | |
| bun add --exact --ignore-scripts "@opencode/protocol@${{ steps.version.outputs.version }}" "effect@${{ steps.version.outputs.effect }}" | |
| bun run extract.ts | |
| - name: Regenerate and verify | |
| run: | | |
| uv sync --locked | |
| uv run python -m codegen | |
| uv run ruff check . | |
| uv run pyright | |
| uv run pytest -m "not live" | |
| - run: git diff > sync.patch | |
| - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: sync-patch | |
| path: sync.patch | |
| pull-request: | |
| # Has write access but only applies the reviewed patch; it runs no project or npm code. | |
| needs: generate | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| name: sync-patch | |
| - name: Apply patch | |
| run: | | |
| if [ -s sync.patch ]; then git apply sync.patch; fi | |
| rm sync.patch | |
| - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| with: | |
| branch: sync/opencode-${{ needs.generate.outputs.version }} | |
| title: "Sync with OpenCode ${{ needs.generate.outputs.version }}" | |
| commit-message: "Sync with OpenCode ${{ needs.generate.outputs.version }}" | |
| body: | | |
| Regenerated from `@opencode/protocol@${{ needs.generate.outputs.version }}`. | |
| Review `api.md` for added, removed or changed operations before merging. | |
| delete-branch: true |