mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix daily-cron failing to bump version (#7129)
* Fix daily-cron failing to bump version Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix variable name Signed-off-by: Sebastian Malton <sebastian@malton.name> --------- Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c575c7a8bd
commit
f678bf4b2e
7 files changed
+1011
-5
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import * as child_process from "child_process";
|
||||
import { readFile, writeFile } from "fs/promises";
|
||||
import semver from "semver";
|
||||
import { promisify } from "util";
|
||||
import arg from "arg";
|
||||
|
||||
const { SemVer } = semver;
|
||||
|
||||
const exec = promisify(child_process.exec);
|
||||
|
||||
const args = arg({
|
||||
"--path": String,
|
||||
});
|
||||
|
||||
const versionJsonPath = args["--path"];
|
||||
|
||||
if (!versionJsonPath) {
|
||||
throw new Error("Missing required '--path'");
|
||||
}
|
||||
|
||||
try {
|
||||
const packageJson = JSON.parse(await readFile(versionJsonPath, "utf-8"));
|
||||
|
||||
const { stdout: gitRevParseOutput } = await exec("git rev-parse --short HEAD");
|
||||
const currentHash = gitRevParseOutput.trim();
|
||||
|
||||
const currentVersion = new SemVer(packageJson.version);
|
||||
|
||||
const partialVersion = `${currentVersion.major}.${currentVersion.minor}.${currentVersion.patch}`;
|
||||
const prereleasePart = `cron.${currentHash}`;
|
||||
const newVersion = `${partialVersion}-${prereleasePart}`;
|
||||
|
||||
await writeFile(
|
||||
versionJsonPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
...packageJson,
|
||||
version: newVersion,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
if (process.env.GITHUB_OUTPUT) {
|
||||
await writeFile(process.env.GITHUB_OUTPUT, `VERSION=${newVersion}`, {
|
||||
flag: "a+",
|
||||
});
|
||||
}
|
||||
|
||||
await exec(`yarn run bump-version --yes ${newVersion}`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user