Skip to content

Commit ad1cbba

Browse files
feat: implement internal dependency synchronization and changelog generation
1 parent 7b6e433 commit ad1cbba

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

.github/workflows/create-release-branch.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ jobs:
252252
253253
let maxVersion = '0.0.0';
254254
const bumpedProjects = [];
255+
const internalVersions = {};
256+
257+
// Helper to increment patch version
258+
function bumpPatch(version) {
259+
const parts = version.split('.');
260+
parts[2] = String(parseInt(parts[2], 10) + 1);
261+
return parts.join('.');
262+
}
255263
256264
// Helper to generate changelog entry
257265
function generateChangelogEntry(version, changelog) {
@@ -291,6 +299,7 @@ jobs:
291299
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
292300
console.error('Updated ' + proj.name + ' to ' + proj.newVersion + ' (' + proj.bump + '): ' + proj.reason);
293301
bumpedProjects.push(proj.name);
302+
internalVersions[proj.name] = proj.newVersion;
294303
295304
// Track max version
296305
if (proj.newVersion.localeCompare(maxVersion, undefined, { numeric: true, sensitivity: 'base' }) > 0) {
@@ -320,6 +329,56 @@ jobs:
320329
}
321330
}
322331
332+
// Second pass: Sync internal dependencies across ALL publishable packages
333+
// If a package depends on a bumped package, update the dep version and patch-bump the dependent
334+
const { execSync } = require('child_process');
335+
let allLibs = [];
336+
try {
337+
const allPublishable = execSync('npx nx show projects -p tag:scope:publishable --type lib --json', { encoding: 'utf8' });
338+
allLibs = JSON.parse(allPublishable);
339+
} catch (e) {
340+
console.error('Warning: Could not get publishable libs for dependency sync');
341+
}
342+
343+
for (const libName of allLibs) {
344+
const pkgPath = 'libs/' + libName + '/package.json';
345+
if (!fs.existsSync(pkgPath)) continue;
346+
347+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
348+
let modified = false;
349+
let needsBump = false;
350+
351+
// Check if any dependency was bumped
352+
if (pkg.dependencies) {
353+
for (const [dep, version] of Object.entries(pkg.dependencies)) {
354+
if (internalVersions[dep] && version !== internalVersions[dep]) {
355+
pkg.dependencies[dep] = internalVersions[dep];
356+
modified = true;
357+
needsBump = true;
358+
console.error('Updated ' + libName + ' dep ' + dep + ' to ' + internalVersions[dep]);
359+
}
360+
}
361+
}
362+
363+
// If this package wasn't already bumped but has updated deps, patch bump it
364+
if (needsBump && !internalVersions[libName]) {
365+
const newVersion = bumpPatch(pkg.version);
366+
pkg.version = newVersion;
367+
internalVersions[libName] = newVersion;
368+
bumpedProjects.push(libName);
369+
console.error('Patch bumped ' + libName + ' to ' + newVersion + ' (dependency update)');
370+
371+
// Update max version
372+
if (newVersion.localeCompare(maxVersion, undefined, { numeric: true, sensitivity: 'base' }) > 0) {
373+
maxVersion = newVersion;
374+
}
375+
}
376+
377+
if (modified) {
378+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
379+
}
380+
}
381+
323382
// Update global changelog
324383
if (output.globalChangelog && bumpedProjects.length > 0) {
325384
const globalPath = 'CHANGELOG.md';

.github/workflows/publish-on-next-close.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
- name: Install dependencies
6464
run: yarn install --frozen-lockfile
6565

66+
- name: Set Nx SHAs
67+
uses: nrwl/nx-set-shas@v4
68+
6669
- name: Find affected publishable libs
6770
id: to_publish
6871
shell: bash
@@ -223,11 +226,41 @@ jobs:
223226
yarn nx run "$project:publish"
224227
done
225228
229+
- name: Generate release body
230+
id: release_body
231+
shell: bash
232+
run: |
233+
set -euo pipefail
234+
235+
PROJECTS="${{ steps.to_publish.outputs.projects }}"
236+
VERSION="${{ steps.version.outputs.version }}"
237+
238+
if [ -n "$PROJECTS" ]; then
239+
# Build release body with published packages info
240+
BODY="## Published Packages\n\n"
241+
242+
IFS=',' read -ra LIBS <<< "$PROJECTS"
243+
for lib in "${LIBS[@]}"; do
244+
if [ -f "libs/$lib/package.json" ]; then
245+
LIB_VERSION=$(node -e "console.log(require('./libs/$lib/package.json').version)")
246+
BODY+="- **${lib}** v${LIB_VERSION} - [npm](https://www.npmjs.com/package/${lib}/v/${LIB_VERSION})\n"
247+
fi
248+
done
249+
250+
BODY+="\n---\n\n"
251+
else
252+
BODY="*No packages published in this release.*\n\n---\n\n"
253+
fi
254+
255+
# Save body to file for multiline support
256+
echo -e "$BODY" > /tmp/release_body.md
257+
226258
- name: Create GitHub Release
227259
uses: softprops/action-gh-release@v2
228260
with:
229261
tag_name: v${{ steps.version.outputs.version }}
230262
name: v${{ steps.version.outputs.version }}
263+
body_path: /tmp/release_body.md
231264
generate_release_notes: true
232265
env:
233266
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

libs/enclave-vm/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "enclave-vm",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Sandbox runtime for secure JavaScript code execution",
55
"author": "AgentFront <info@agentfront.dev>",
66
"homepage": "https://github.com/agentfront/enclave",
@@ -36,7 +36,7 @@
3636
}
3737
},
3838
"dependencies": {
39-
"ast-guard": "1.0.0",
39+
"ast-guard": "1.1.0",
4040
"acorn": "8.15.0",
4141
"acorn-walk": "8.3.4",
4242
"astring": "1.9.0",

0 commit comments

Comments
 (0)