Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"git": {
"commitMessage": "chore: release v${version} [skip ci]",
"tagName": "v${version}",
"tagMatch": "v*",
"tagAnnotation": "Release v${version}",
"requireBranch": "main",
"requireCleanWorkingDir": true,
Expand All @@ -21,7 +22,7 @@
"hooks": {
"after:bump": "tsx tools/sync-versions.ts ${version} && pnpm build:notice && git add NOTICE.md",
"before:release": "pnpm build && pnpm --filter=docs build && pnpm --filter=@databricks/appkit dist && pnpm --filter=@databricks/appkit-ui dist",
"after:release": "npm publish packages/appkit/tmp --access public --provenance && npm publish packages/appkit-ui/tmp --access public --provenance"
"after:release": "npm publish packages/appkit/tmp --access public --provenance && npm publish packages/appkit-ui/tmp --access public --provenance && tsx tools/publish-template-tag.ts ${version}"
},
"plugins": {
"@release-it/conventional-changelog": {
Expand Down
129 changes: 121 additions & 8 deletions template/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"license": "Unlicensed",
"description": "{{.app_description}}",
"dependencies": {
"@databricks/appkit": "0.5.2",
"@databricks/appkit-ui": "0.5.2",
"@databricks/appkit": "0.6.0",
"@databricks/appkit-ui": "0.6.0",
"@databricks/sdk-experimental": "^0.14.2",
"clsx": "^2.1.1",
"embla-carousel-react": "^8.6.0",
Expand Down
89 changes: 89 additions & 0 deletions tools/publish-template-tag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env tsx
/**
* Run after npm publish. Syncs the template to the new version (with retry),
* then commits, tags template-vX.X.X, and pushes.
*/

import { spawnSync } from "node:child_process";
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";

const ROOT = process.cwd();
const version = process.argv[2];
if (!version) {
console.error("Usage: tsx tools/publish-template-tag.ts <version>");
process.exit(1);
}

function run(cmd: string, args: string[], opts: { cwd?: string } = {}): number {
const result = spawnSync(cmd, args, {
cwd: opts.cwd ?? ROOT,
stdio: "inherit",
shell: true,
});
return result.status ?? 1;
}

// 1. Update template package.json
const templatePath = join(ROOT, "template", "package.json");
const templateJson = JSON.parse(readFileSync(templatePath, "utf-8"));
if (templateJson.dependencies) {
if ("@databricks/appkit" in templateJson.dependencies) {
templateJson.dependencies["@databricks/appkit"] = version;
}
if ("@databricks/appkit-ui" in templateJson.dependencies) {
templateJson.dependencies["@databricks/appkit-ui"] = version;
}
writeFileSync(templatePath, `${JSON.stringify(templateJson, null, 2)}\n`);
console.log(`✓ template/package.json → ${version}`);
}

// 2. npm install in template (with retry for registry propagation)
const MAX_ATTEMPTS = 3;
const templateDir = join(ROOT, "template");

function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

async function runNpmInstallWithRetry(): Promise<number> {
let lastStatus = 0;
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
const status = run("npm", ["install"], { cwd: templateDir });
lastStatus = status;
if (status === 0) {
console.log("✓ template/package-lock.json updated (npm install)");
return 0;
}
if (attempt < MAX_ATTEMPTS) {
const delayMs = 2 ** attempt * 1000;
console.warn(
`npm install failed (attempt ${attempt}/${MAX_ATTEMPTS}), retrying in ${delayMs / 1000}s...`,
);
await sleep(delayMs);
}
}
return lastStatus;
}

const installExit = await runNpmInstallWithRetry();
if (installExit !== 0) {
console.error(`npm install failed after ${MAX_ATTEMPTS} attempts`);
process.exit(installExit);
}

// 3. Git add, commit, tag, push
const commands: [string, string[]][] = [
["git", ["add", "template/package.json", "template/package-lock.json"]],
["git", ["commit", "-m", `chore: sync template to v${version}`]],
["git", ["tag", `template-v${version}`]],
["git", ["push", "origin", "main", "--follow-tags"]],
];

for (const [command, args] of commands) {
if (run(command, args) !== 0) {
process.exit(1);
}
}

console.log(`✓ template tag template-v${version} pushed`);