mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Add getCurrentVersion
This commit is contained in:
@@ -12,6 +12,9 @@ export const REPO_ROOT = path.join(PR_CHECKS_DIR, "..");
|
||||
/** The path of the file configuring which checks shouldn't be required. */
|
||||
export const PR_CHECK_EXCLUDED_FILE = path.join(PR_CHECKS_DIR, "excluded.yml");
|
||||
|
||||
/** The path of the main `package.json`. */
|
||||
export const PACKAGE_JSON = path.join(REPO_ROOT, "package.json");
|
||||
|
||||
/** The path to the esbuild metadata file. */
|
||||
export const BUNDLE_METADATA_FILE = path.join(REPO_ROOT, "meta.json");
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
|
||||
import * as fs from "node:fs";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { PACKAGE_JSON } from "./config";
|
||||
|
||||
/** Placeholder changelog content for a new release. */
|
||||
const EMPTY_CHANGELOG = `# CodeQL Action Changelog
|
||||
|
||||
@@ -46,6 +49,14 @@ export function getGitHubToken(): string {
|
||||
throw new Error("Missing GitHub token. Set GITHUB_TOKEN or GH_TOKEN.");
|
||||
}
|
||||
|
||||
/** Reads the current version from `package.json`. */
|
||||
export function getCurrentVersion(): string | undefined {
|
||||
const pkg: { version: string } = JSON.parse(
|
||||
fs.readFileSync(PACKAGE_JSON, "utf8"),
|
||||
);
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
interface MainOptions {
|
||||
repositoryNwo: string;
|
||||
sourceBranch: string;
|
||||
@@ -102,6 +113,15 @@ async function main(): Promise<void> {
|
||||
RELEASE_BRANCH_PREFIX,
|
||||
"",
|
||||
);
|
||||
|
||||
const currentVersion = getCurrentVersion();
|
||||
|
||||
if (!currentVersion) {
|
||||
throw new Error("Failed to read current version from package.json");
|
||||
}
|
||||
|
||||
const [, vMinor, vPatch] = currentVersion.split(".");
|
||||
const version = `${targetBranchMajorVersion}.${vMinor}.${vPatch}`;
|
||||
}
|
||||
|
||||
// Only call `main` if this script was run directly.
|
||||
|
||||
Reference in New Issue
Block a user