-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
7 changed files
with
1,011 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/swcrc", | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript" | ||
}, | ||
"target": "es2022" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@k8slens/bump-version-for-cron", | ||
"version": "6.4.0-cron.4db172da60", | ||
"description": "CLI to bump the version to during a cron daily alpha release", | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rimraf dist/", | ||
"build": "swc ./src/index.ts -d ./dist" | ||
}, | ||
"type": "module", | ||
"bin": "./dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"dependencies": { | ||
"arg": "^5.0.2", | ||
"semver": "^7.3.8" | ||
}, | ||
"devDependencies": { | ||
"@swc/cli": "^0.1.61", | ||
"@swc/core": "^1.3.32", | ||
"@types/node": "^16.18.11", | ||
"@types/semver": "^7.3.13", | ||
"rimraf": "^4.1.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"outDir": "dist/", | ||
"paths": { | ||
"*": [ | ||
"node_modules/*", | ||
"types/*" | ||
] | ||
}, | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
] | ||
} |
Oops, something went wrong.