versionary 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/index.js +30 -0
- package/dist/ci.d.ts +7 -0
- package/dist/ci.js +53 -0
- package/dist/cli/index.js +12 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/config.d.ts +1 -0
- package/package.json +2 -1
package/dist/action/index.js
CHANGED
|
@@ -104,7 +104,37 @@ function skipRun(action, message) {
|
|
|
104
104
|
setOutput("branch", "");
|
|
105
105
|
setOutput("title", "");
|
|
106
106
|
}
|
|
107
|
+
function runCi() {
|
|
108
|
+
const cwd = getInput("working-directory") || ".";
|
|
109
|
+
const version = getInput("versionary-version") || "0.7.0";
|
|
110
|
+
const raw = execFileSync("npx", ["--yes", `versionary@${version}`, "ci", "--json"], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
111
|
+
let payload;
|
|
112
|
+
try {
|
|
113
|
+
payload = JSON.parse(raw);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
throw new Error("Failed parsing Versionary CI JSON output.");
|
|
117
|
+
}
|
|
118
|
+
if (payload?.action !== "ci-evaluated" ||
|
|
119
|
+
typeof payload.runChecks !== "boolean" ||
|
|
120
|
+
typeof payload.isReleasePr !== "boolean") {
|
|
121
|
+
throw new Error("Versionary returned an invalid CI decision.");
|
|
122
|
+
}
|
|
123
|
+
process.stdout.write(`${raw}\n`);
|
|
124
|
+
setOutput("action", payload.action);
|
|
125
|
+
setOutput("message", payload.message ?? "");
|
|
126
|
+
setOutput("run_checks", String(payload.runChecks));
|
|
127
|
+
setOutput("is_release_pr", String(payload.isReleasePr));
|
|
128
|
+
}
|
|
107
129
|
function main() {
|
|
130
|
+
const command = getInput("command") || "run";
|
|
131
|
+
if (command === "ci") {
|
|
132
|
+
runCi();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (command !== "run") {
|
|
136
|
+
throw new Error(`Unsupported command "${command}". Expected "run" or "ci".`);
|
|
137
|
+
}
|
|
108
138
|
const token = getInput("token");
|
|
109
139
|
if (!token) {
|
|
110
140
|
if (isForkRepository()) {
|
package/dist/ci.d.ts
ADDED
package/dist/ci.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { loadConfig } from "./config/load-config.js";
|
|
4
|
+
import { resolveSeparateReleaseBranchPrefix } from "./release/cohorts.js";
|
|
5
|
+
const pullRequestSchema = z.object({
|
|
6
|
+
pull_request: z.object({
|
|
7
|
+
head: z.object({
|
|
8
|
+
ref: z.string().min(1),
|
|
9
|
+
repo: z.object({ full_name: z.string().min(1) }),
|
|
10
|
+
}),
|
|
11
|
+
base: z.object({ repo: z.object({ full_name: z.string().min(1) }) }),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
function readPullRequest(env) {
|
|
15
|
+
if ((env.GITHUB_EVENT_NAME !== "pull_request" &&
|
|
16
|
+
env.GITHUB_EVENT_NAME !== "pull_request_target") ||
|
|
17
|
+
!env.GITHUB_EVENT_PATH) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const result = pullRequestSchema.safeParse(JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, "utf8")));
|
|
22
|
+
return result.success ? result.data.pull_request : null;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Incomplete event context must never suppress checks.
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function evaluateCi(cwd = process.cwd(), env = process.env) {
|
|
30
|
+
const { config } = loadConfig(cwd);
|
|
31
|
+
const request = readPullRequest(env);
|
|
32
|
+
const repository = env.GITHUB_REPOSITORY?.trim().toLowerCase();
|
|
33
|
+
const releaseBranch = resolveSeparateReleaseBranchPrefix(config["release-branch"] ?? "versionary/release");
|
|
34
|
+
const headBranch = request?.head.ref ?? "";
|
|
35
|
+
const separateBranch = config["separate-release-prs"] === true &&
|
|
36
|
+
headBranch.startsWith(`${releaseBranch}-`) &&
|
|
37
|
+
/^[A-Za-z0-9._-]+-[a-f0-9]{12}$/u.test(headBranch.slice(releaseBranch.length + 1));
|
|
38
|
+
const isReleasePr = Boolean(config["review-mode"] !== "direct" &&
|
|
39
|
+
releaseBranch &&
|
|
40
|
+
repository &&
|
|
41
|
+
request?.head.repo.full_name.toLowerCase() === repository &&
|
|
42
|
+
request?.base.repo.full_name.toLowerCase() === repository &&
|
|
43
|
+
(headBranch === releaseBranch || separateBranch));
|
|
44
|
+
const runChecks = config["release-pr-checks"] !== "skip" || !isReleasePr;
|
|
45
|
+
return {
|
|
46
|
+
action: "ci-evaluated",
|
|
47
|
+
message: runChecks
|
|
48
|
+
? "CI checks are enabled."
|
|
49
|
+
: `Skipping checks for Versionary release PR ${headBranch}.`,
|
|
50
|
+
runChecks,
|
|
51
|
+
isReleasePr,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/dist/cli/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
|
+
import { evaluateCi } from "../ci.js";
|
|
5
6
|
import { writeCommitOverride } from "../config/commit-overrides.js";
|
|
6
7
|
import { loadConfig } from "../config/load-config.js";
|
|
7
8
|
import { resolveCommitSha } from "../git/commit-overrides.js";
|
|
@@ -277,6 +278,16 @@ async function main() {
|
|
|
277
278
|
const [, , command, ...args] = process.argv;
|
|
278
279
|
const flags = parseFlags(args);
|
|
279
280
|
const logger = flags.json ? undefined : console;
|
|
281
|
+
if (command === "ci") {
|
|
282
|
+
const decision = evaluateCi();
|
|
283
|
+
if (flags.json) {
|
|
284
|
+
emitJson(decision);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
console.log(decision.message);
|
|
288
|
+
}
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
280
291
|
if (!command || command === "run") {
|
|
281
292
|
if (loadConfig(process.cwd()).config["review-mode"] === "direct") {
|
|
282
293
|
const release = await runDirectRelease(process.cwd(), {
|
|
@@ -582,6 +593,7 @@ async function main() {
|
|
|
582
593
|
console.log("Commands:");
|
|
583
594
|
console.log(" run [--json] [--dry-run] Auto-dispatch release PR/update or release publish by context");
|
|
584
595
|
console.log(" verify Validate config and basic repository shape");
|
|
596
|
+
console.log(" ci [--json] Decide whether CI should run checks");
|
|
585
597
|
console.log(" plan Print release plan");
|
|
586
598
|
console.log(' exclude <sha> [--reason "..."] Exclude a commit from release analysis and notes');
|
|
587
599
|
console.log(' correct <sha> --message "..." [--reason "..."] Correct a commit for release analysis and notes');
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare const configSchema: z.ZodObject<{
|
|
|
10
10
|
external: "external";
|
|
11
11
|
versionary: "versionary";
|
|
12
12
|
}>>;
|
|
13
|
+
"release-pr-checks": z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
run: "run";
|
|
15
|
+
skip: "skip";
|
|
16
|
+
}>>;
|
|
13
17
|
"version-file": z.ZodOptional<z.ZodString>;
|
|
14
18
|
"changelog-file": z.ZodOptional<z.ZodString>;
|
|
15
19
|
"changelog-format": z.ZodOptional<z.ZodEnum<{
|
package/dist/config/schema.js
CHANGED
|
@@ -110,6 +110,10 @@ export const configSchema = z
|
|
|
110
110
|
version: z.literal(1),
|
|
111
111
|
"review-mode": z.enum(["direct", "pr"]).optional(),
|
|
112
112
|
"release-mode": z.enum(["versionary", "external"]).optional(),
|
|
113
|
+
"release-pr-checks": z
|
|
114
|
+
.enum(["run", "skip"])
|
|
115
|
+
.optional()
|
|
116
|
+
.describe("Whether CI integration runs checks on Versionary release PRs."),
|
|
113
117
|
"version-file": z.string().optional(),
|
|
114
118
|
"changelog-file": z.string().optional(),
|
|
115
119
|
"changelog-format": z.enum(["markdown-changelog", "r-news"]).optional(),
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/types/config.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface VersionaryConfig {
|
|
|
36
36
|
version: 1;
|
|
37
37
|
"review-mode"?: "direct" | "pr";
|
|
38
38
|
"release-mode"?: "versionary" | "external";
|
|
39
|
+
"release-pr-checks"?: "run" | "skip";
|
|
39
40
|
"version-file"?: string;
|
|
40
41
|
"changelog-file"?: string;
|
|
41
42
|
"changelog-format"?: VersionaryChangelogFormat;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versionary",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Automatic release framework based on conventional commits and semantic versioning",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"releasing",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"gen:schema": "tsx scripts/generate-schema.ts && biome format --write schemas/config.json",
|
|
50
50
|
"test": "vitest run",
|
|
51
51
|
"verify": "tsx src/cli/index.ts verify",
|
|
52
|
+
"ci": "tsx src/cli/index.ts ci",
|
|
52
53
|
"run": "tsx src/cli/index.ts run",
|
|
53
54
|
"plan": "tsx src/cli/index.ts plan",
|
|
54
55
|
"exclude": "tsx src/cli/index.ts exclude",
|