-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag-and-promote.js
More file actions
45 lines (37 loc) · 1.56 KB
/
tag-and-promote.js
File metadata and controls
45 lines (37 loc) · 1.56 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
#!/usr/bin/env node
/**
* Tag and promote a ModelKit across environments.
*
* A common release workflow:
* 1. CI publishes a release candidate to a staging registry.
* 2. After QA sign-off, the same digest is promoted to production by
* re-tagging — no re-packing, no risk of bit-rot between environments.
*
* Run: node examples/tag-and-promote.js
*/
import { login, pull, tag, push, inspect, logout } from '../dist/index.js';
const stagingRegistry = process.env.STAGING_REGISTRY ?? 'staging.example.com';
const prodRegistry = process.env.PROD_REGISTRY ?? 'registry.example.com';
const user = process.env.REGISTRY_USER ?? '';
const pass = process.env.REGISTRY_PASS ?? '';
const rcRef = `${stagingRegistry}/org/my-model:rc1`;
const v1Ref = `${prodRegistry}/org/my-model:v1.0.0`;
const latestRef = `${prodRegistry}/org/my-model:latest`;
// --- Inspect the candidate before promoting ---
const metadata = await inspect('org/my-model', 'rc1', { remote: true });
console.log(`Promoting digest: ${metadata.digest}`);
console.log(`Kit version: ${metadata.cliVersion}`);
// --- Pull the RC so we can tag it locally ---
await login(stagingRegistry, user, pass);
await pull(rcRef);
await logout(stagingRegistry);
// Create two local aliases: a versioned tag and a floating "latest".
await tag(rcRef, v1Ref);
await tag(rcRef, latestRef);
console.log(`Tagged as ${v1Ref} and ${latestRef}`);
// --- Push both tags to production ---
await login(prodRegistry, user, pass);
await push(v1Ref);
await push(latestRef);
await logout(prodRegistry);
console.log('Promotion complete.');