Skip to content

Commit f9223d1

Browse files
demos
1 parent 63b69f8 commit f9223d1

File tree

5 files changed

+214
-1
lines changed

5 files changed

+214
-1
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ jobs:
120120
run: npm install --package-lock-only
121121

122122
- name: Publish to npm
123-
run: npx changeset publish
123+
run: |
124+
if [ "${{ inputs.release_type }}" = "pre-release (next)" ]; then
125+
npx changeset publish --tag next
126+
else
127+
npx changeset publish
128+
fi
124129
env:
125130
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
126131

@@ -161,6 +166,20 @@ jobs:
161166
CLI_VERSION=$(node -p "require('./packages/cli/package.json').version")
162167
echo "cli=$CLI_VERSION" >> $GITHUB_OUTPUT
163168
169+
- name: Verify CLI published to npm
170+
run: |
171+
CLI_VERSION=${{ steps.versions.outputs.cli }}
172+
for i in 1 2 3 4 5; do
173+
if npm view "@walkeros/cli@$CLI_VERSION" version 2>/dev/null; then
174+
echo "Verified: @walkeros/cli@$CLI_VERSION exists on npm"
175+
exit 0
176+
fi
177+
echo "Attempt $i: waiting for npm propagation..."
178+
sleep 10
179+
done
180+
echo "ERROR: @walkeros/cli@$CLI_VERSION not found on npm after publish"
181+
exit 1
182+
164183
- name: Check if Flow image exists
165184
id: check-flow
166185
run: |

.github/workflows/storybook.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy Storybook
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'apps/demos/storybook/**'
8+
- 'apps/storybook-addon/**'
9+
- '.github/workflows/storybook.yml'
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
env:
20+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
21+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: '22'
28+
cache: 'npm'
29+
30+
- run: corepack enable
31+
- run: npm ci
32+
- run: npm run build
33+
34+
- name: Build Storybook
35+
working-directory: apps/demos/storybook
36+
run: npm run build-storybook
37+
38+
- name: Deploy to Bunny
39+
working-directory: apps/demos/storybook
40+
run: node scripts/deploy-bunny.mjs
41+
env:
42+
BUNNY_STORAGE_ZONE: ${{ secrets.BUNNY_STORYBOOK_STORAGE_ZONE }}
43+
BUNNY_STORAGE_PASSWORD: ${{ secrets.BUNNY_STORYBOOK_STORAGE_PASSWORD }}
44+
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }}
45+
BUNNY_PULLZONE_URL: ${{ secrets.BUNNY_STORYBOOK_PULLZONE_URL }}

.github/workflows/tagging.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy Tagging Demo
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'apps/demos/tagging/**'
8+
- '.github/workflows/tagging.yml'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: '22'
24+
25+
- name: Deploy to Bunny
26+
working-directory: apps/demos/tagging
27+
run: node scripts/deploy-bunny.mjs
28+
env:
29+
BUNNY_STORAGE_ZONE: ${{ secrets.BUNNY_TAGGING_STORAGE_ZONE }}
30+
BUNNY_STORAGE_PASSWORD: ${{ secrets.BUNNY_TAGGING_STORAGE_PASSWORD }}
31+
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }}
32+
BUNNY_PULLZONE_URL: ${{ secrets.BUNNY_TAGGING_PULLZONE_URL }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { readdir, readFile } from 'node:fs/promises';
2+
import { join, relative } from 'node:path';
3+
4+
const STORAGE_ZONE = process.env.BUNNY_STORAGE_ZONE;
5+
const STORAGE_PASSWORD = process.env.BUNNY_STORAGE_PASSWORD;
6+
const API_KEY = process.env.BUNNY_API_KEY;
7+
const PULLZONE_URL = process.env.BUNNY_PULLZONE_URL;
8+
const STORAGE_URL = `https://storage.bunnycdn.com/${STORAGE_ZONE}`;
9+
10+
async function getFiles(dir) {
11+
const entries = await readdir(dir, { withFileTypes: true, recursive: true });
12+
return entries.filter((e) => e.isFile()).map((e) => join(e.parentPath, e.name));
13+
}
14+
15+
async function uploadFile(localPath, remotePath) {
16+
const content = await readFile(localPath);
17+
const res = await fetch(`${STORAGE_URL}/${remotePath}`, {
18+
method: 'PUT',
19+
headers: { AccessKey: STORAGE_PASSWORD, 'Content-Type': 'application/octet-stream' },
20+
body: content,
21+
});
22+
if (!res.ok) throw new Error(`Upload failed: ${remotePath} (${res.status})`);
23+
console.log(`✓ ${remotePath}`);
24+
}
25+
26+
async function purgeCache() {
27+
const res = await fetch(`https://api.bunny.net/purge?url=${encodeURIComponent(`${PULLZONE_URL}/*`)}`, {
28+
method: 'POST',
29+
headers: { AccessKey: API_KEY },
30+
});
31+
if (!res.ok) {
32+
const text = await res.text();
33+
throw new Error(`Purge failed: ${res.status} - ${text}`);
34+
}
35+
console.log('✓ Cache purged');
36+
}
37+
38+
async function deploy() {
39+
const outDir = 'storybook-static';
40+
const files = await getFiles(outDir);
41+
console.log(`Uploading ${files.length} files...`);
42+
43+
for (const file of files) {
44+
const remotePath = relative(outDir, file);
45+
await uploadFile(file, remotePath);
46+
}
47+
48+
await purgeCache();
49+
console.log('Deploy complete!');
50+
}
51+
52+
deploy().catch((e) => {
53+
console.error(e);
54+
process.exit(1);
55+
});
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { readdir, readFile } from 'node:fs/promises';
2+
import { join, relative } from 'node:path';
3+
4+
const STORAGE_ZONE = process.env.BUNNY_STORAGE_ZONE;
5+
const STORAGE_PASSWORD = process.env.BUNNY_STORAGE_PASSWORD;
6+
const API_KEY = process.env.BUNNY_API_KEY;
7+
const PULLZONE_URL = process.env.BUNNY_PULLZONE_URL;
8+
const STORAGE_URL = `https://storage.bunnycdn.com/${STORAGE_ZONE}`;
9+
10+
const EXCLUDE = new Set(['node_modules', 'scripts', 'package.json', 'package-lock.json', 'README.md']);
11+
12+
async function getFiles(dir) {
13+
const entries = await readdir(dir, { withFileTypes: true, recursive: true });
14+
return entries
15+
.filter((e) => {
16+
if (!e.isFile()) return false;
17+
const rel = relative(dir, join(e.parentPath, e.name));
18+
return !rel.split('/').some((part) => EXCLUDE.has(part));
19+
})
20+
.map((e) => join(e.parentPath, e.name));
21+
}
22+
23+
async function uploadFile(localPath, remotePath) {
24+
const content = await readFile(localPath);
25+
const res = await fetch(`${STORAGE_URL}/${remotePath}`, {
26+
method: 'PUT',
27+
headers: { AccessKey: STORAGE_PASSWORD, 'Content-Type': 'application/octet-stream' },
28+
body: content,
29+
});
30+
if (!res.ok) throw new Error(`Upload failed: ${remotePath} (${res.status})`);
31+
console.log(`✓ ${remotePath}`);
32+
}
33+
34+
async function purgeCache() {
35+
const res = await fetch(`https://api.bunny.net/purge?url=${encodeURIComponent(`${PULLZONE_URL}/*`)}`, {
36+
method: 'POST',
37+
headers: { AccessKey: API_KEY },
38+
});
39+
if (!res.ok) {
40+
const text = await res.text();
41+
throw new Error(`Purge failed: ${res.status} - ${text}`);
42+
}
43+
console.log('✓ Cache purged');
44+
}
45+
46+
async function deploy() {
47+
const files = await getFiles('.');
48+
console.log(`Uploading ${files.length} files...`);
49+
50+
for (const file of files) {
51+
const remotePath = relative('.', file);
52+
await uploadFile(file, remotePath);
53+
}
54+
55+
await purgeCache();
56+
console.log('Deploy complete!');
57+
}
58+
59+
deploy().catch((e) => {
60+
console.error(e);
61+
process.exit(1);
62+
});

0 commit comments

Comments
 (0)