Repository navigation
80 lines (75 loc) · 2.98 KB
/
Copy pathsync-spec.yml
File metadata and controls
80 lines (75 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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