-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix daily-cron failing to bump version #7129
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this come from before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came from the extensions which have this as a script instead of a package.