Skip to content

Commit 5311547

Browse files
committed
Add missing version-script.ts file.
This was referenced from the prerelease job but didn't make it into the original PR.
1 parent eb754dd commit 5311547

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/version-script.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as fs from "node:fs";
2+
import { execSync } from "node:child_process";
3+
async function main() {
4+
try {
5+
console.log("Getting current git hash...");
6+
const stdout = execSync("git rev-parse --short HEAD").toString();
7+
console.log("Git hash:", stdout.trim());
8+
9+
const path = "./package.json";
10+
const packageJson = JSON.parse(fs.readFileSync(path, "utf-8"));
11+
packageJson.version = `0.0.0-${stdout.trim()}`;
12+
fs.writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`);
13+
} catch (error) {
14+
console.error(error);
15+
process.exit(1);
16+
}
17+
}
18+
19+
main().catch((err) => {
20+
// Build failures should fail
21+
console.error(err);
22+
process.exit(1);
23+
});

0 commit comments

Comments
 (0)