-
Notifications
You must be signed in to change notification settings - Fork 0
351 lines (314 loc) · 13.3 KB
/
release.yml
File metadata and controls
351 lines (314 loc) · 13.3 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
name: Release
on:
push:
branches:
- main
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
env:
HUSKY: 0
PUPPETEER_SKIP_DOWNLOAD: 1
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
jobs:
build-and-pack:
name: Build & Pack
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
packages: ${{ steps.list.outputs.packages }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
~/.local/share/pnpm/store
~/.cache/pnpm
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build All Packages
run: pnpm build
- name: Pack Packages
id: pack
run: |
mkdir -p tarballs
for pkg in next-images next-compose-plugins next-optimized-images next-mdx next-mdx-toc next-session next-auth react-virtualized; do
cd packages/$pkg
pnpm pack --pack-destination ../../tarballs/ > /dev/null 2>&1
cd ../..
done
echo "packages=[\"next-images\",\"next-compose-plugins\",\"next-optimized-images\",\"next-mdx\",\"next-mdx-toc\",\"next-session\",\"next-auth\",\"react-virtualized\"]" >> "$GITHUB_OUTPUT"
- name: List tarballs
run: ls -la tarballs/
- name: Upload tarballs
uses: actions/upload-artifact@v4
with:
name: package-tarballs
path: tarballs/
retention-days: 1
compat-matrix:
name: Compat (${{ matrix.package }}, Next ${{ matrix.next-version }})
needs: build-and-pack
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
package:
[
next-images,
next-compose-plugins,
next-optimized-images,
next-mdx,
next-session,
next-auth,
react-virtualized,
]
next-version: ['14.2.24', '15.2.0', '16.1.6']
include:
- next-version: '14.2.24'
react-version: '18.3.1'
- next-version: '15.2.0'
react-version: '19.0.0'
- next-version: '16.1.6'
react-version: '19.2.0'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Download tarballs
uses: actions/download-artifact@v4
with:
name: package-tarballs
path: tarballs/
- name: Run smoke test
env:
SMOKE_PACKAGE: ${{ matrix.package }}
SMOKE_NEXT: ${{ matrix.next-version }}
SMOKE_REACT: ${{ matrix.react-version }}
run: |
set -euo pipefail
TARBALL_DIR="$(pwd)/tarballs"
TEMP_DIR=$(mktemp -d)
find_tarball() {
local pkg="$1"
ls "$TARBALL_DIR"/opensourceframework-"$pkg"-*.tgz 2>/dev/null | head -1
}
# next-mdx also needs next-mdx-toc
if [ "$SMOKE_PACKAGE" = "next-mdx" ]; then
MDX_TARBALL=$(find_tarball next-mdx)
MDX_TOC_TARBALL=$(find_tarball next-mdx-toc)
if [ -z "$MDX_TARBALL" ] || [ -z "$MDX_TOC_TARBALL" ]; then
echo "Missing tarballs for next-mdx compat test"
exit 1
fi
else
TARBALL=$(find_tarball "$SMOKE_PACKAGE")
if [ -z "$TARBALL" ]; then
echo "Missing tarball for $SMOKE_PACKAGE"
exit 1
fi
fi
case "$SMOKE_PACKAGE" in
next-images)
FIXTURE="$TEMP_DIR/next-images"
mkdir -p "$FIXTURE/assets" "$FIXTURE/pages"
BUILD_CMD="next build"
[ "$SMOKE_NEXT" = "16.1.6" ] && BUILD_CMD="next build --webpack"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"scripts":{"build":"$BUILD_CMD"},"dependencies":{"@opensourceframework/next-images":"file:$TARBALL","next":"$SMOKE_NEXT","react":"$SMOKE_REACT","react-dom":"$SMOKE_REACT"}}
EOF
cat > "$FIXTURE/next.config.js" <<'EOF'
const withImages = require('@opensourceframework/next-images');
module.exports = withImages({ fileExtensions: ['svg'], inlineImageLimit: false });
EOF
cat > "$FIXTURE/pages/index.js" <<'EOF'
import logo from '../assets/logo.svg';
export default function Home() { return <main><img src={logo} alt="logo" /></main>; }
EOF
echo '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="4" fill="red"/></svg>' > "$FIXTURE/assets/logo.svg"
cd "$FIXTURE" && pnpm install --reporter append-only && pnpm build
;;
next-compose-plugins)
FIXTURE="$TEMP_DIR/next-compose-plugins"
mkdir -p "$FIXTURE"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"dependencies":{"@opensourceframework/next-compose-plugins":"file:$TARBALL"}}
EOF
cat > "$FIXTURE/smoke.cjs" <<'EOF'
const assert = require('node:assert/strict');
const withPlugins = require('@opensourceframework/next-compose-plugins');
assert.equal(typeof withPlugins, 'function');
assert.equal(typeof withPlugins.optional, 'function');
assert.equal(typeof withPlugins.extend, 'function');
EOF
cd "$FIXTURE" && pnpm install --reporter append-only && node smoke.cjs
;;
next-optimized-images)
FIXTURE="$TEMP_DIR/next-optimized-images"
mkdir -p "$FIXTURE/assets" "$FIXTURE/pages"
BUILD_CMD="next build"
[ "$SMOKE_NEXT" = "16.1.6" ] && BUILD_CMD="next build --webpack"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"scripts":{"build":"$BUILD_CMD"},"dependencies":{"@opensourceframework/next-optimized-images":"file:$TARBALL","next":"$SMOKE_NEXT","react":"$SMOKE_REACT","react-dom":"$SMOKE_REACT"}}
EOF
cat > "$FIXTURE/next.config.js" <<'EOF'
const withOptimizedImages = require('@opensourceframework/next-optimized-images');
module.exports = withOptimizedImages({ handleImages: ['svg'], inlineImageLimit: false, optimizeImages: false });
EOF
cat > "$FIXTURE/pages/index.js" <<'EOF'
import logo from '../assets/logo.svg';
export default function Home() { return <main><img src={logo} alt="logo" /></main>; }
EOF
echo '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="4" fill="blue"/></svg>' > "$FIXTURE/assets/logo.svg"
cd "$FIXTURE" && pnpm install --reporter append-only && pnpm build
;;
next-mdx)
FIXTURE="$TEMP_DIR/next-mdx"
mkdir -p "$FIXTURE/content/posts"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"dependencies":{"@opensourceframework/next-mdx":"file:$MDX_TARBALL","@opensourceframework/next-mdx-toc":"file:$MDX_TOC_TARBALL","next":"$SMOKE_NEXT","react":"$SMOKE_REACT","react-dom":"$SMOKE_REACT"}}
EOF
cat > "$FIXTURE/next-mdx.config.mjs" <<'EOF'
export default { post: { contentPath: 'content/posts', basePath: '/blog' } };
EOF
cat > "$FIXTURE/content/posts/hello.mdx" <<'EOF'
---
title: Hello World
date: 2026-03-11
---
# Heading One
This is a compatibility smoke test.
## Heading Two
EOF
cat > "$FIXTURE/smoke.cjs" <<'EOF'
const assert = require('node:assert/strict');
const { getMdxNode, getMdxPaths } = require('@opensourceframework/next-mdx/server');
const { getTableOfContents } = require('@opensourceframework/next-mdx-toc');
(async () => {
const node = await getMdxNode('post', 'hello');
assert.equal(node.frontMatter.title, 'Hello World');
assert.equal(node.url, '/blog/hello');
const paths = await getMdxPaths('post');
assert.deepEqual(paths, [{ params: { slug: ['hello'] } }]);
const toc = await getTableOfContents(node);
assert.equal(toc.items?.[0]?.title, 'Heading One');
assert.equal(toc.items?.[0]?.items?.[0]?.title, 'Heading Two');
})().catch(e => { console.error(e); process.exit(1); });
EOF
cd "$FIXTURE" && pnpm install --reporter append-only && node smoke.cjs
;;
next-session)
FIXTURE="$TEMP_DIR/next-session"
mkdir -p "$FIXTURE"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"dependencies":{"@opensourceframework/next-session":"file:$TARBALL"}}
EOF
cat > "$FIXTURE/smoke.cjs" <<'EOF'
const assert = require('node:assert/strict');
const nextSession = require('@opensourceframework/next-session');
const compat = require('@opensourceframework/next-session/lib/compat');
assert.equal(typeof nextSession, 'function');
assert.equal(typeof compat.expressSession, 'function');
assert.equal(typeof compat.promisifyStore, 'function');
EOF
cd "$FIXTURE" && pnpm install --reporter append-only && node smoke.cjs
;;
next-auth)
FIXTURE="$TEMP_DIR/next-auth"
mkdir -p "$FIXTURE"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"dependencies":{"@opensourceframework/next-auth":"file:$TARBALL"}}
EOF
cat > "$FIXTURE/smoke.cjs" <<'EOF'
const assert = require('node:assert/strict');
const GoogleProvider = require('@opensourceframework/next-auth/providers/google');
assert.equal(typeof GoogleProvider, 'function');
assert.equal(GoogleProvider({ clientId: 'id', clientSecret: 'secret' }).id, 'google');
EOF
cat > "$FIXTURE/smoke.mjs" <<'EOF'
import assert from 'node:assert/strict';
import GoogleProvider from '@opensourceframework/next-auth/providers/google';
assert.equal(typeof GoogleProvider, 'function');
assert.equal(GoogleProvider({ clientId: 'id', clientSecret: 'secret' }).id, 'google');
EOF
cd "$FIXTURE" && pnpm install --reporter append-only && node smoke.cjs && node smoke.mjs
;;
react-virtualized)
FIXTURE="$TEMP_DIR/react-virtualized"
mkdir -p "$FIXTURE"
cat > "$FIXTURE/package.json" <<EOF
{"name":"compat","private":true,"dependencies":{"@opensourceframework/react-virtualized":"file:$TARBALL","react":"$SMOKE_REACT","react-dom":"$SMOKE_REACT"}}
EOF
cat > "$FIXTURE/smoke.cjs" <<'EOF'
const assert = require('node:assert/strict');
const React = require('react');
const { renderToStaticMarkup } = require('react-dom/server');
const { List } = require('@opensourceframework/react-virtualized');
const html = renderToStaticMarkup(
React.createElement(List, {
width: 200, height: 100, rowCount: 2, rowHeight: 20,
rowRenderer: ({ key, index, style }) => React.createElement('div', { key, style }, `Row ${index}`),
})
);
assert.match(html, /Row 0/);
assert.match(html, /ReactVirtualized__List/);
EOF
cd "$FIXTURE" && pnpm install --reporter append-only && node smoke.cjs
;;
*)
echo "Unknown package: $SMOKE_PACKAGE"
exit 1
;;
esac
echo "✅ $SMOKE_PACKAGE compat test passed with Next.js $SMOKE_NEXT / React $SMOKE_REACT"
- name: Cleanup
if: always()
run: rm -rf /tmp/osf-compat-* 2>/dev/null || true
release:
name: Publish
needs: [build-and-pack, compat-matrix]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Install Dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build All Packages
run: pnpm build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}