Skip to content

Commit daf00eb

Browse files
authored
Merge pull request #6565 from elizaOS/shaw/release-clean-tree-fix
Shaw/release clean tree fix
2 parents 84135db + 4c08722 commit daf00eb

5 files changed

Lines changed: 323 additions & 0 deletions

File tree

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Publish Alpha Prerelease
2+
3+
on:
4+
push:
5+
branches:
6+
- shaw/release-clean-tree-fix
7+
paths:
8+
- .github/workflows/publish-next-prerelease.yaml
9+
10+
jobs:
11+
publish-next:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
id-token: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "23.3.0"
28+
registry-url: "https://registry.npmjs.org"
29+
30+
- name: Setup Bun
31+
uses: oven-sh/setup-bun@v2
32+
with:
33+
bun-version: "1.3.4"
34+
35+
- name: Install Linux system libraries
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y \
39+
libpq-dev \
40+
postgresql-client \
41+
pkg-config \
42+
libatspi2.0-dev \
43+
libgtk-3-dev \
44+
libx11-dev \
45+
libxcb1-dev \
46+
libxcb-randr0-dev \
47+
libxkbcommon-dev \
48+
libwayland-dev \
49+
libpipewire-0.3-dev \
50+
libgbm-dev \
51+
libdrm-dev \
52+
libegl1-mesa-dev
53+
54+
- name: Install dependencies
55+
run: bun install
56+
57+
- name: Install Rust toolchain
58+
uses: dtolnay/rust-toolchain@stable
59+
with:
60+
targets: wasm32-unknown-unknown
61+
62+
- name: Install wasm-pack
63+
run: cargo install wasm-pack
64+
65+
- name: Configure Git
66+
run: |
67+
git config user.name "github-actions[bot]"
68+
git config user.email "github-actions[bot]@users.noreply.github.com"
69+
70+
- name: Compute next prerelease version
71+
id: version
72+
run: |
73+
CURRENT=$(npm view @elizaos/core versions --json | node -e '
74+
const fs = require("fs");
75+
const versions = JSON.parse(fs.readFileSync(0, "utf8"));
76+
const prereleases = versions
77+
.filter((version) => /^2\.0\.0-alpha(?:\.\d+)?$/.test(version))
78+
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
79+
process.stdout.write(prereleases.at(-1) ?? "2.0.0-alpha.0");
80+
')
81+
82+
if [[ "${CURRENT}" =~ ^2\.0\.0-alpha\.([0-9]+)$ ]]; then
83+
NEXT="2.0.0-alpha.$((BASH_REMATCH[1] + 1))"
84+
elif [[ "${CURRENT}" == "2.0.0-alpha" ]]; then
85+
NEXT="2.0.0-alpha.1"
86+
else
87+
echo "Unexpected prerelease version: ${CURRENT}"
88+
exit 1
89+
fi
90+
91+
echo "current=${CURRENT}" >> $GITHUB_OUTPUT
92+
echo "next=${NEXT}" >> $GITHUB_OUTPUT
93+
echo "Publishing ${NEXT} to dist-tag alpha"
94+
95+
- name: Bump package versions
96+
run: |
97+
bunx lerna version "${{ steps.version.outputs.next }}" \
98+
--force-publish \
99+
--yes \
100+
--no-private \
101+
--allow-branch shaw/release-clean-tree-fix \
102+
--no-git-tag-version \
103+
--no-push
104+
105+
- name: Update lockfile
106+
run: bun install --no-frozen-lockfile
107+
108+
- name: Create local version commit
109+
run: |
110+
git add -A
111+
git commit -m "chore: prepare v${{ steps.version.outputs.next }} for next publish [skip ci]"
112+
113+
- name: Build WASM packages
114+
run: |
115+
echo "Building WASM packages..."
116+
117+
cd packages/rust
118+
wasm-pack build --target web --out-dir pkg/web --features wasm --no-default-features || echo "WASM web build skipped"
119+
wasm-pack build --target nodejs --out-dir pkg/node --features wasm --no-default-features || echo "WASM node build skipped"
120+
cd ../..
121+
122+
if [ -d "plugins/plugin-sql/rust" ]; then
123+
cd plugins/plugin-sql/rust
124+
wasm-pack build --target web --out-dir pkg/web --features wasm --no-default-features || echo "WASM web build skipped"
125+
wasm-pack build --target nodejs --out-dir pkg/node --features wasm --no-default-features || echo "WASM node build skipped"
126+
cd ../../..
127+
fi
128+
129+
- name: Build packages
130+
run: bun run build
131+
132+
- name: Ensure clean tree before publish
133+
run: |
134+
git checkout -- packages/elizaos/examples-manifest.json || true
135+
136+
if [[ -n "$(git status --porcelain)" ]]; then
137+
echo "❌ Working tree must be clean before publish."
138+
git status --short
139+
exit 1
140+
fi
141+
142+
- name: Publish to NPM with alpha tag
143+
env:
144+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
145+
run: |
146+
bunx lerna publish from-package \
147+
--dist-tag alpha \
148+
--force-publish \
149+
--yes \
150+
--no-verify-access

.github/workflows/release.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,14 @@ jobs:
602602
603603
echo "✅ Successfully published to NPM with dist-tag: ${DIST_TAG}"
604604
605+
- name: Sync next dist-tag for 2.0 prereleases
606+
if: steps.release_type.outputs.type == 'alpha'
607+
env:
608+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
609+
run: |
610+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
611+
node scripts/sync-prerelease-dist-tags.js alpha next
612+
605613
# Kept for workflow compatibility; no-op because replacement is no-op.
606614
- name: Restore workspace references
607615
if: always() && steps.replace_workspace.outcome == 'success'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Sync Next Dist-Tags
2+
3+
on:
4+
push:
5+
branches:
6+
- shaw/release-clean-tree-fix
7+
workflow_dispatch:
8+
inputs:
9+
source_tag:
10+
description: Source dist-tag to mirror
11+
required: false
12+
default: alpha
13+
type: string
14+
target_tag:
15+
description: Target dist-tag to update
16+
required: false
17+
default: next
18+
type: string
19+
20+
jobs:
21+
sync:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "23.3.0"
34+
registry-url: "https://registry.npmjs.org"
35+
36+
- name: Sync dist-tags
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
run: |
40+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
41+
node scripts/sync-prerelease-dist-tags.js "${{ inputs.source_tag || 'alpha' }}" "${{ inputs.target_tag || 'next' }}"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"release:next": "cd ../eliza-workspace && bash publish-ordered.sh",
3131
"release:next:dry-run": "cd ../eliza-workspace && bash publish-ordered.sh --dry-run",
3232
"release:next:lerna": "bunx lerna publish from-package --dist-tag next --force-publish --yes --no-verify-access",
33+
"release:sync-next": "node scripts/sync-prerelease-dist-tags.js alpha next",
3334
"release:beta": "bunx lerna publish from-package --dist-tag beta --force-publish --yes --no-verify-access",
3435
"release:alpha": "bunx lerna publish from-package --dist-tag alpha --force-publish --yes --no-verify-access",
3536
"version:alpha": "bunx lerna version prerelease --preid alpha --force-publish --yes --no-push --no-git-tag-version",
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env node
2+
3+
import { readdirSync, readFileSync } from "node:fs";
4+
import { join, relative } from "node:path";
5+
import { spawnSync } from "node:child_process";
6+
import { fileURLToPath } from "node:url";
7+
8+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
9+
const repoRoot = join(__dirname, "..");
10+
const packagesRoot = join(repoRoot, "packages");
11+
12+
const sourceTag = process.argv[2] || "alpha";
13+
const targetTag = process.argv[3] || "next";
14+
15+
function walkPackageJsonFiles(dir, results = []) {
16+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
17+
if (
18+
entry.name === "node_modules" ||
19+
entry.name === "dist" ||
20+
entry.name === "target" ||
21+
entry.name === ".turbo"
22+
) {
23+
continue;
24+
}
25+
26+
const fullPath = join(dir, entry.name);
27+
28+
if (entry.isDirectory()) {
29+
walkPackageJsonFiles(fullPath, results);
30+
continue;
31+
}
32+
33+
if (entry.isFile() && entry.name === "package.json") {
34+
results.push(fullPath);
35+
}
36+
}
37+
38+
return results;
39+
}
40+
41+
function runNpm(args, { allowFailure = false } = {}) {
42+
const result = spawnSync("npm", args, {
43+
cwd: repoRoot,
44+
encoding: "utf8",
45+
});
46+
47+
if (result.status === 0) {
48+
return result.stdout.trim();
49+
}
50+
51+
if (allowFailure) {
52+
return "";
53+
}
54+
55+
const stderr = result.stderr.trim();
56+
throw new Error(stderr || `npm ${args.join(" ")} failed`);
57+
}
58+
59+
function collectManagedPackages() {
60+
const names = new Map();
61+
62+
for (const packageJsonPath of walkPackageJsonFiles(packagesRoot)) {
63+
const raw = readFileSync(packageJsonPath, "utf8");
64+
const pkg = JSON.parse(raw);
65+
66+
if (pkg.private === true || typeof pkg.name !== "string") {
67+
continue;
68+
}
69+
70+
if (!pkg.name.startsWith("@elizaos/")) {
71+
continue;
72+
}
73+
74+
names.set(pkg.name, relative(repoRoot, packageJsonPath));
75+
}
76+
77+
return [...names.entries()].sort(([a], [b]) => a.localeCompare(b));
78+
}
79+
80+
const packages = collectManagedPackages();
81+
let updated = 0;
82+
83+
console.log(
84+
`Syncing dist-tags for ${packages.length} package(s): ${sourceTag} -> ${targetTag}`,
85+
);
86+
87+
for (const [packageName, packageJsonPath] of packages) {
88+
const rawTags = runNpm(["view", packageName, "dist-tags", "--json"], {
89+
allowFailure: true,
90+
});
91+
92+
if (!rawTags) {
93+
console.log(`- skip ${packageName} (${packageJsonPath}): no dist-tags found`);
94+
continue;
95+
}
96+
97+
let tags;
98+
try {
99+
tags = JSON.parse(rawTags);
100+
} catch (_error) {
101+
console.log(`- skip ${packageName} (${packageJsonPath}): invalid dist-tags`);
102+
continue;
103+
}
104+
105+
const sourceVersion = tags[sourceTag];
106+
if (!sourceVersion) {
107+
console.log(`- skip ${packageName} (${packageJsonPath}): no ${sourceTag} tag`);
108+
continue;
109+
}
110+
111+
if (tags[targetTag] === sourceVersion) {
112+
console.log(`- ok ${packageName}: ${targetTag} already ${sourceVersion}`);
113+
continue;
114+
}
115+
116+
runNpm(["dist-tag", "add", `${packageName}@${sourceVersion}`, targetTag]);
117+
updated += 1;
118+
console.log(
119+
`- set ${packageName}: ${targetTag} -> ${sourceVersion} (from ${sourceTag})`,
120+
);
121+
}
122+
123+
console.log(`Done. Updated ${updated} package(s).`);

0 commit comments

Comments
 (0)