-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (188 loc) · 7.1 KB
/
Copy pathrelease.yml
File metadata and controls
225 lines (188 loc) · 7.1 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Publish release
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
env:
CLAWHUB_OWNER: serpapi
jobs:
test:
name: Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [22, 24]
steps:
- name: Check out the released revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
with:
version: 10.33.1
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install locked dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Typecheck
run: pnpm run typecheck
build:
name: Build release distribution
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the released revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
with:
version: 10.33.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: pnpm
- name: Install locked dependencies
run: pnpm install --frozen-lockfile
- name: Verify the release tag matches the package version
if: github.event_name == 'release'
shell: bash
run: |
package_version="$(node -p "require('./package.json').version")"
if [[ "${GITHUB_REF_NAME}" != "v${package_version}" ]]; then
echo "Release tag ${GITHUB_REF_NAME} must equal v${package_version}." >&2
exit 1
fi
- name: Build
run: pnpm run build
- name: Pack the release tarball
# The tarball is only used to verify the exact files ClawHub receives,
# so it is packed the same way ClawHub packs: `--ignore-scripts`, so a
# future prepare/prepack script cannot make the two diverge. The
# compiled output is never rebuilt after this point.
run: npm pack --ignore-scripts
- name: Upload the release tarball
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: release-tarball
path: "*.tgz"
if-no-files-found: error
retention-days: 7
- name: Upload the compiled output
# ClawHub packs a working directory rather than a tarball, so it needs
# `dist/` on disk. Reusing this artifact keeps it byte-identical to the
# verified tarball.
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: compiled-output
path: dist/
if-no-files-found: error
retention-days: 7
verify:
name: Verify the built tarball
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out the released revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- name: Download the release tarball
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: release-tarball
path: artifact/
- name: Install the tarball against the supported host
shell: bash
run: |
host_version="$(node -p "require('./package.json').devDependencies.openclaw")"
mkdir -p "${RUNNER_TEMP}/smoke"
cd "${RUNNER_TEMP}/smoke"
npm init -y > /dev/null
npm pkg set type=module > /dev/null
npm install --no-audit --no-fund \
"${GITHUB_WORKSPACE}"/artifact/*.tgz \
"openclaw@${host_version}"
- name: Load the plugin entry point
shell: bash
run: |
cd "${RUNNER_TEMP}/smoke"
node --input-type=module -e '
const manifest = await import(
"@serpapi/openclaw-plugin/package.json",
{ with: { type: "json" } }
);
const [entry] = manifest.default.openclaw.extensions;
const plugin = (await import(`@serpapi/openclaw-plugin/${entry.slice(2)}`)).default;
if (typeof plugin?.register !== "function") {
throw new Error(`Plugin ${entry} exposes no register() function.`);
}
console.log(`Loaded ${plugin.id} (${plugin.name}) from ${entry}.`);
'
- name: Install the ClawHub CLI
run: npm install -g clawhub@latest
- name: ClawHub validate the packed contents
# Validate the extracted tarball rather than the repository, so the
# check runs against the exact files ClawHub receives.
shell: bash
run: |
mkdir -p "${RUNNER_TEMP}/packed"
tar -xzf artifact/*.tgz -C "${RUNNER_TEMP}/packed"
clawhub package validate "${RUNNER_TEMP}/packed/package"
publish-clawhub:
name: Publish to ClawHub
# `workflow_dispatch` stops after `verify`: publishing must always come from
# a published release so the checked-out ref is the release tag.
if: github.event_name == 'release'
needs: verify
runs-on: ubuntu-latest
environment:
name: release
url: https://clawhub.ai/serpapi
steps:
- name: Check out the released revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- name: Download the compiled output
# ClawHub packs the folder with `npm pack --ignore-scripts`, so `dist/`
# must be on disk before publishing. It is restored from the verified
# build rather than rebuilt here.
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: compiled-output
path: dist/
- name: Install the ClawHub CLI
run: npm install -g clawhub@latest
- name: Sign in to ClawHub
env:
CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }}
run: |
if [ -z "$CLAWHUB_TOKEN" ]; then
echo "::error::CLAWHUB_TOKEN secret is required to publish."
exit 1
fi
clawhub login --token "$CLAWHUB_TOKEN"
clawhub whoami
- name: ClawHub publish (dry run)
run: |
clawhub package publish . \
--family code-plugin \
--owner "$CLAWHUB_OWNER" \
--dry-run
- name: ClawHub publish
run: |
clawhub package publish . \
--family code-plugin \
--owner "$CLAWHUB_OWNER"