Skip to content

Commit 37f0d4f

Browse files
committedSep 30, 2024·
ci: make nightly versions human readable
1 parent da42b05 commit 37f0d4f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎scripts/bump-nightly.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,28 @@ async function loadWorkspace(dir: string) {
105105
};
106106
}
107107

108+
function fmtDate(d: Date): string {
109+
// YYMMDD-HHMMSS: 20240919-140954
110+
const date = joinNumbers([d.getFullYear(), d.getMonth() + 1, d.getDate()]);
111+
const time = joinNumbers([d.getHours(), d.getMinutes(), d.getSeconds()]);
112+
return `${date}-${time}`;
113+
}
114+
115+
function joinNumbers(items: number[]): string {
116+
return items.map((i) => (i + "").padStart(2, "0")).join("");
117+
}
118+
108119
async function main() {
109120
const workspace = await loadWorkspace(process.cwd());
110121

111122
const commit = await execaCommand("git rev-parse --short HEAD").then((r) =>
112123
r.stdout.trim()
113124
);
114-
const date = Math.round(Date.now() / (1000 * 60));
115125

116126
for (const pkg of workspace.packages.filter((p) => !p.data.private)) {
117127
workspace.setVersion(
118128
pkg.data.name,
119-
`${pkg.data.version}-${date}.${commit}`
129+
`${pkg.data.version}-${fmtDate(new Date())}.${commit}`
120130
);
121131
workspace.rename(pkg.data.name, pkg.data.name + "-nightly");
122132
pkg.updateDeps((dep) => {

0 commit comments

Comments
 (0)
Please sign in to comment.